Controller
//栏目所有信息
public ActionResult Sublistes(string id, int page=1)
{
int totalCount;
IList<Vcontent> content = factory.GetContentBusiness().getlmState(id, 1, 20, out totalCount);
IQueryable<Vcontent> conten = content.AsQueryable();
PagedList<Vcontent> cont = conten.ToPagedList(page, 2);
return PartialView("Sublistes", cont);
}
页面
<div id="articles">
@Html.Action("Sublistes", "Default", new { id = @Model[0].Menu})
</div>
分布视图
类型@model PagedList<Model.ViewObjects.Vcontent>
@foreach (var lis in Model)
{
布局页面
}
分页控件: 注意PageIndexParameterName = "page" 中 page是Controller中代表页数的值 也就是 int page=1这个值
@Ajax.Pager(Model, new PagerOptions { PageIndexParameterName = "page", ShowPageIndexBox = true, PageIndexBoxType = PageIndexBoxType.DropDownList, ShowGoButton = false }, new MvcAjaxOptions { UpdateTargetId = "articles" })