Adding Index View
As usual, we have to call the model that being thrown from controller. Then use the model along the view.
@model IEnumerable<PlaylistGenreMvc.Models.SongModel>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
We can give a navigation link too.
<p>
@Html.ActionLink("Create New", "Create")
</p>
The key is creating a table with header and data row, which is a result from looping method on songModel collection model.
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Title)
</th>
..
..
..
..
..
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
..
..
..
..
..
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}
</table>