我正在制作一个 MVC3 Web 应用程序。我有一个表格,里面装满了我的数据库中的数据,但我想知道如何让它只显示概要的前三行而不是全部 10 行。我认为这有关系使用 HTML Helpers 但想知道是否有人可以帮我找到正确的代码??????任何帮助都会很棒!
@model IEnumerable<TheatreGroup.Models.Show>
@{
ViewBag.Title = "Shows";
}
<h2>
Shows</h2>
<p>Below is a list of shows which will be avalible in the next couple of weeks</p>
<p>
@Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm())
{
<p>
Find by name: @Html.TextBox("SearchString")
<input type="submit" value="Search" /></p>
}
<table>
<tr>
<th>
@Html.ActionLink("name", "Index", new { sortOrder = ViewBag.nameSortParm,})
</th>
<th>
@Html.ActionLink("writer", "Index", new { sortOrder = ViewBag.writerSortParm,})
</th>
<th>
@Html.ActionLink("synopsis", "Index", new { sortOrder = ViewBag.synopsisSortParm, })
</th>
<th>
</th>
</tr>
@foreach (var item in Model){
<tr>
<td>
@Html.DisplayFor(modelItem => item.name)
</td>
<td>
@Html.DisplayFor(modelItem => item.writer)
</td>
<td>
@Html.DisplayFor(modelItem => item.synopsis)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.showid }) |
@Html.ActionLink("Details", "Details", new { id = item.showid }) |
@Html.ActionLink("Delete", "Delete", new { id = item.showid })
</td>
</tr>
}
</table>