Hi,you can try the following code. Assume you get the 'author' value in the Controller.
public async Task<IActionResult> Display()
{
var author = new List<Author>
{
new Author { Name = "Test1", Book = "Apress1", Price = 49.95 },
new Author { Name = "Test2", Book = "Apress2", Price = 19.95 },
new Author { Name = "Test3", Book = "Press3", Price = 29.95 }
};
return View(author);
}
And the Display.cshtml
@model List<Author>
<table class="table table-bordered table-responsive table-hover">
<tr>
<th>Name </th>
<th>Book </th>
<th>Price </th>
</tr>
@foreach (var d in Model)
{
<tr>
<td>@d.Name</td>
<td>@d.Book</td>
<td>@d.Price</td>
</tr>
}
</table>
The output
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.