{
using (var db = new NORTHWNDEntities())
{
PagedList<Orders> orders = db.Orders.OrderBy(o=>o.OrderID).ToPagedList(id, 20);
return View(orders);
}
}
2.前台页面:
ViewBag.Title = "MvcPager标准Url分页";
}
@model PagedList<Orders>
<h1>MvcPager标准Url分页</h1>
<table width="98%">
<tr><th>订单编号</th><th>订单日期</th><th>顾客编号</th><th>收货地址</th></tr>
@foreach (Orders od in Model)
{
<tr><td>@od.OrderID</td><td>@od.OrderDate.ToString()</td><td>@od.CustomerID</td>
<td>@od.ShipAddress</td></tr>
}
</table>
@Html.Pager(Model,new PagerOptions{PageIndexParameterName=" id"})