【发布时间】:2016-04-24 03:36:35
【问题描述】:
我有一个 Mvc 表,它看起来像这样:
<table id="example" class="table table-hover">
<thead>
<tr>
<th>SL NO
</th>
<th>Designation Name
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
//Here I want Serial No here [I used Paging]
</td>
<td>
@Html.DisplayFor(modelItem => item.desigantionName)
</td>
<td>
<div class="btn btn-default btn-lg disabled p-x-2">@Html.ActionLink("Edit", "Edit", new { id = item.desigantionId }) </div>
<div class="btn btn-default btn-lg disabled p-x-2">@Html.ActionLink("Details", "Details", new { id = item.desigantionId }) </div>
<div class="btn btn-default btn-lg disabled p-x-2">@Html.ActionLink("Delete", "Delete", new { id = item.desigantionId })</div>
</td>
</tr>
}
</tbody>
</table>
上面的代码第一列我想要序列号我使用 sl 不使用 css 但问题是当转到下一页索引 sl 没有重新启动到 1 每个寻呼机我用了 5 行我需要开始第二页索引 sl no up to 6
【问题讨论】:
-
如何检索模型?获取模型数据时,您必须注意偏移量。您可以在模型中添加一些索引吗?
-
你的问题几乎没有意义。你怎么可能使用 jQuery 或 CSS 来呈现序列号?除非您的意思是“索引”,或者您只想在每个项目上都有一个序号,例如
1,2,3,4,<new page> 5,6,7,8(在这种情况下,正如@derpirscher 所说,您必须知道偏移量)?如果你的意思是序列号,它必须是你正在渲染的项目的一个属性,它必须是唯一的,所以你不能只是在前端凭空生成它,它不会与分页有任何关系。为什么不能只渲染item.serialNumber或任何该属性的名称?
标签: c# html css asp.net-mvc