2013-09-27 51 views
2
<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> 

当前我在显示25项每页。如果最后一个页面没有25个项目,我想将行追加到表格的最后,以将页面选择器保持在页面之间的同一级别。 这似乎是它的工作,我只是不知道在哪里把它:将行添加到页面列表的最后一页

@for (int i = 25; i > Model.Attachments.Count() % 25; i--) 
{ 
    <tr> 
     <td></td> 
    </tr> 
} 

回答

0

您有一定的循环抛出的附件列表。 把这个循环放在你写TR的循环之后。

只要考虑到如果您的数据让您的TR更高,这将打破您的解决方案。您可能尝试的其他操作是在虚拟行中添加一个HTML空间:&nbsp;

<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> 
相关问题