C# 仅刷新一次数据源的ASP.NET MVC分页表?
如果您愿意使用这种分页方法,那么finde中的所有内容都可以正常工作。我的问题是,我不想每次都获取数据集。我只想做一次。我该怎么做? 表:C# 仅刷新一次数据源的ASP.NET MVC分页表?,c#,asp.net,asp.net-mvc,twitter-bootstrap,C#,Asp.net,Asp.net Mvc,Twitter Bootstrap,如果您愿意使用这种分页方法,那么finde中的所有内容都可以正常工作。我的问题是,我不想每次都获取数据集。我只想做一次。我该怎么做? 表: 你不想使用jquery datatable吗?@Vivek Singh如果你认为有比这个更好的解决方案,请给我发一个链接。看看这个=> @model PagedList.IPagedList<ViewModel.QuestionViewModel> @using PagedList.Mvc; <table class="table">
你不想使用jquery datatable吗?@Vivek Singh如果你认为有比这个更好的解决方案,请给我发一个链接。看看这个=>
@model PagedList.IPagedList<ViewModel.QuestionViewModel>
@using PagedList.Mvc;
<table class="table">
<tr class="table-head">
<th>
<p>Sender</p>
</th>
<th>
<p>Subject</p>
</th>
<th>
<p>Received</p>
</th>
<th>
<p>HasAttachment</p>
</th>
<th></th>
</tr>
@foreach (var item in Model.Inbox) {
<tr class="mail-row" onclick="location.href = '@Url.Action("Index", "MailContent", new { id = item.Id })'">
<td>
@Html.DisplayFor(modelItem => item.From)
</td>
<td>
@Html.DisplayFor(modelItem => item.Subject)
</td>
<td>
@Html.DisplayFor(modelItem => item.Received)
</td>
<td>
@Html.DisplayFor(modelItem => item.HasAttachments)
</td>
<td>
@Html.DisplayFor(modelItem => item.AssetClass)
</td>
<td>
@Html.DisplayFor(modelItem => item.InProgressBy)
</td>
@*<td>
@html.actionlink("edit", "edit", new { /* id=item.primarykey */ }) |
@html.actionlink("details", "details", new { /* id=item.primarykey */ }) |
@html.actionlink("delete", "delete", new { /* id=item.primarykey */ })
</td>*@
</tr>
}
</table>
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager( Model, page => Url.Action("MailList", new { page }) )
public ActionResult MailList(string id, int? page) {
//TODO: get list
//get Maillist for mailbox
context = new InboxToolContext();
context.Mails.MailboxType = id;
Console.Write(i);
i = 2;
int pageSize = 20;
int pageNumber = (page ?? 1);
return View(context.Mails.All().ToPagedList(pageNumber,pageSize));
}