etrupja / complete-ecommerce-aspnet-mvc-application

This is the source code of the "ASP.NET MVC | Build a Complete eCommerce App" course on Udemy
https://bit.ly/3CWvkqk
261 stars 300 forks source link

In View @foreach loop not working it shows error!!! #9

Open AmitRathod07 opened 1 year ago

AmitRathod07 commented 1 year ago

Screenshot 2023-03-29 163043

    <table>
        <thead>
            <tr>
                <th>@Html.DisplayNameFor(model => model.ProfilePictureURL)</th>
                <th>@Html.DisplayNameFor(model => model.FullName)</th>
                <th>@Html.DisplayNameFor(model => model.Bio)</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            **@foreach (var item in Model)**
            {
                <tr>
                    <td class="align-middle">
                        <img class="rounded-circle" src="@item.ProfilePictureURL" alt="@item.FullName" style="max-width: 150px" />
                    </td>
                    <td class="align-middle">
                        @Html.DisplayFor(modelItem => item.FullName)
                    </td>
                    <td class="align-middle">
                        @Html.DisplayFor(modelItem => item.Bio)
                    </td>
                    <td class="align-middle">
                        <a class="btn btn-outline-primary"><i class="bi bi-pencil-square"></i>Edit </a> |
                        <a class="btn btn-outline-info"><i class="bi bi-eye"></i>Details </a> |
                        <a class="btn btn-danger text-white"><i class="bi bi-trash"></i>Delete </a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
saikodari commented 1 year ago

@AmitRathod07 may be the model your retrieving from controller is null

Yogesh0775 commented 1 year ago

return view(data); on Actors Controller

dwarwick commented 1 year ago

Maybe data is null.