标签:des cPage blog http io ar for div sp
http://www.webdiyer.com/mvcpager/downloads/ 下载 MvcPagerDemoNet4.0.zip
新建MVC 项目引用 下载下来的 MvcPager.dll
然后在要分页的Controllers index 方法中 修改成
public ActionResult Index(int? page = 1) { var ggxxlook = db.GGXX.OrderByDescending(s => s.id); return View(ggxxlook.ToPagedList(page ?? 1, 5)); }
视图中 index 加入
@model PagedList<MvcApplication3.Models.相关的类> @using Webdiyer.WebControls.Mvc;
分页条写在视图最下面
<p>共有 @Model.TotalItemCount 条记录 @Model.CurrentPageIndex/@Model.TotalPageCount</p> @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "page", ShowPageIndexBox = true, PageIndexBoxType = PageIndexBoxType.TextBox, PageIndexBoxWrapperFormatString = "请输入页数{0}" }, "Default", new { sortOrder = ViewBag.DateSortParm, searchString = ViewBag.Filter })
config 中加入
<pages> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Optimization" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages" /> <add namespace="Webdiyer.WebControls.Mvc"/> <!--添加这个 --> </namespaces> </pages>
标签:des cPage blog http io ar for div sp
原文地址:http://www.cnblogs.com/crazyair/p/3976718.html