asp.net mvc - How to list DB data like this in MVC4? -
it's easy list data in rows.
controller:
return view(xxx.tolist());
view:
@model ienumerable<mvcproject.models.table1> @foreach (var item in model) { <table style="width: 100%"> ........ ..... </table> }
but how can list data in viewpage in mvc4?
without changing data structure, following (assuming model doesn't have lot of items in it):
edit: requested in comments, i've added each header row contains 5 items:
<table> <tr> @for (int = 0; < model.count(); i++) { <th>@item.id</th> @if ((i + 1) % 5 == 0) { @:</tr><tr> } } </tr> @foreach(var item in model) { <tr> <td>@* data on item *@</td> </tr> } </table>
Comments
Post a Comment