将List<T>中的数据以列表的形式显示在MVC页面中:
主要代码如下:
@model IEnumerable<xxx_H.Models.EntitySampleClass>
<div class="col-md-10">
<table class="tabletable-striped table-hover" style="background-color: white">
<tr style="border-bottom-style:double">
<th style="padding:1px 3px;width:20px;">
<label>№</label>
</th>
<th style="padding:1px 3px;width:400px;">
<label>F_1</label>
</th>
<th style="padding:1px 3px;width:100px;">
<label>F_2</label>
</th>
<th></th>
</tr>
@if (Model != null)
{
foreach (var item in Model)
{
<tr>
<td style="padding:1px 3px">
@Html.DisplayFor(modelItem => item.SampleClass_No)
</td>
<td style="padding:1px 3px">
@Html.DisplayFor(modelItem => item.SampleClass_F_1)
</td>
<td style="padding:1px 3px">
@Html.DisplayFor(modelItem => item.SampleClass_F_2)
</td>
</tr>
}
}
</table>
<div style="padding-bottom: 2em"></div>
</div>