C# 向页面列表的最后一页添加行 客户ID 名称 类型 @foreach(模型附件中的变量a) { @a、 CId @a、 CType } @Html.PagedListPager((IPagedList)Model.Attachments,page=>Url.Action(“Index”,new{page}))
目前我每页显示25个项目。如果最后一个页面没有25个项目,我想在表的末尾追加行,以使页面选择器在页面之间保持相同的级别。 这似乎是可行的,我只是不知道该放在哪里:C# 向页面列表的最后一页添加行 客户ID 名称 类型 @foreach(模型附件中的变量a) { @a、 CId @a、 CType } @Html.PagedListPager((IPagedList)Model.Attachments,page=>Url.Action(“Index”,new{page})),c#,html,asp.net-mvc,C#,Html,Asp.net Mvc,目前我每页显示25个项目。如果最后一个页面没有25个项目,我想在表的末尾追加行,以使页面选择器在页面之间保持相同的级别。 这似乎是可行的,我只是不知道该放在哪里: <div> <table > <tr> <th>Customer ID</th> <th>Name</th> <th>Type</th&
<div>
<table >
<tr>
<th>Customer ID</th>
<th>Name</th>
<th>Type</th>
</tr>
@foreach (var a in Model.Attachments)
{
<tr>
<td>
@a.CId
</td>
<td>
<a href="@Url.Action("ViewAttachment", new { Id = a.CId })">@a.CName</a>
</td>
<td>
@a.CType
</td>
</tr>
}
</table>
@Html.PagedListPager((IPagedList)Model.Attachments, page => Url.Action("Index", new { page }))
</div>
@for(int i=25;i>Model.Attachments.Count()%25;i--)
{
}
您肯定在附件列表中抛出了一个循环。
把这个循环放在你写TRs的循环后面
只要考虑到,如果您的数据使您的TRs更高,这将破坏您的解决方案。您可以尝试的另一件事是在虚拟行中添加HTML空间:
@for (int i = 25; i > Model.Attachments.Count() % 25; i--)
{
<tr>
<td></td>
</tr>
}
客户ID
名称
类型
@foreach(模型附件中的变量a)
{
@a、 CId
@a、 CType
}
@对于(int i=25;i>Model.Attachments.Count()%25;i--)
{
}
@Html.PagedListPager((IPagedList)Model.Attachments,page=>Url.Action(“Index”,new{page}))
<div>
<table >
<tr>
<th>Customer ID</th>
<th>Name</th>
<th>Type</th>
</tr>
@foreach (var a in Model.Attachments)
{
<tr>
<td>
@a.CId
</td>
<td>
<a href="@Url.Action("ViewAttachment", new { Id = a.CId })">@a.CName</a>
</td>
<td>
@a.CType
</td>
</tr>
}
@for (int i = 25; i > Model.Attachments.Count() % 25; i--)
{
<tr>
<td></td>
</tr>
}
</table>
@Html.PagedListPager((IPagedList)Model.Attachments, page => Url.Action("Index", new { page }))
</div>