我在显示有关如何包含上一个和下一个链接的页面时遇到问题...我正在使用 ASP.Net MVC 4 使用这些代码:
看法:
<div class="pagination">
<ul>
@for (int i = 1; i <= ViewBag.PagesCount; i++)
{
<text>
<li>@Html.ActionLink(i.ToString(), "Index", new { pagee = i })</li>
</text>
}
</ul>
</div>
控制器:
int offset = 15;
int pagecount = ((pagee - 1) * offset);
int totalPages = 0;
int totalItems = 0;
try
{
totalItems = requestform.Count();
while (totalItems > 0)
{
totalItems -= 15;
totalPages++;
}
ViewBag.PagesCount = totalPages;
return View(requestform.Skip(pagecount).Take(offset).ToList());
}
catch
{
while (totalItems > 0)
{
totalItems -= 15;
totalPages++;
}
ViewBag.PagesCount = totalPages;
return View(requestform.Skip(pagecount).Take(offset).ToList());
}
请帮我解决一下这个。