I am trying to build a table in my view with values from the model. My model in the foreach loop is null. Is there something I could be missing in my controller?
My View (cshtml)
@model IEnumerable<MyApp.Models.BookModel>
@{
ViewData["Title"] = "Index";
}
<table>
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.bookName)
</th>
<th>
@Html.DisplayNameFor(model => model.Author)
</th>
</tr>
</thead>
<tbody>
@foreach(var b in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => b.bookName)
</td>
<td>
@Html.DisplayFor(modelItem => b.Author)
</td>
</tr>
}
</tbody>
</table>
Thanks!
