标签:
MVC分页
1.Install Package
Tools=> NuGet Package Manager=>Manager NuGet Packages of Solution
安装 X.PagedList和X.PagedList.MVC
package.config文件: <package id="X.PagedList" version="1.24.1.300" targetFramework="net45" />
<package id="X.PagedList.Mvc" version="4.9.1.310" targetFramework="net45" />
View界面:
@model PagedList.IPagedList<T>
@using PagedList
@using PagedList.Mvc
@Html.PagedListPager(Model, page => Url.Action("ActionName", new { page }))
//分页控件
controller:
public ActionResult ActionName(int? page)
{
int PageNumber=page?? 1;//page为null时默认值为1
int PageSize=10;
return View(list.ToPagedList(PageNumber,PageSize));
}
标签:
原文地址:http://www.cnblogs.com/huangchenqin/p/5336501.html