MvcPager分页控件
标准Url分页示例
插入分页控件代码:
<%=Html.Pager(Model,new PagerOptions{PageIndexParameterName="id"}) %>
| 订单编号 | 订单日期 | 顾客编号 | 收货地址 |
|---|---|---|---|
| 11060 | 1998/4/30 0:00:00 | FRANS | Via Monte Bianco 34 |
| 11061 | 1998/4/30 0:00:00 | GREAL | 2732 Baker Blvd. |
| 11062 | 1998/4/30 0:00:00 | REGGC | Strada Provinciale 124 |
| 11063 | 1998/4/30 0:00:00 | HUNGO | 8 Johnstown Road |
| 11064 | 1998/5/1 0:00:00 | SAVEA | 187 Suffolk Ln. |
| 11065 | 1998/5/1 0:00:00 | LILAS | Carrera 52 con Ave. Bolívar #65-98 Llano Largo |
| 11066 | 1998/5/1 0:00:00 | WHITC | 1029 - 12th Ave. S. |
| 11067 | 1998/5/4 0:00:00 | DRACD | Walserweg 21 |
| 11068 | 1998/5/4 0:00:00 | QUEEN | Alameda dos Canàrios, 891 |
| 11069 | 1998/5/4 0:00:00 | TORTU | Avda. Azteca 123 |
| 11070 | 1998/5/5 0:00:00 | LEHMS | Magazinweg 7 |
| 11071 | 1998/5/5 0:00:00 | LILAS | Carrera 52 con Ave. Bolívar #65-98 Llano Largo |
| 11072 | 1998/5/5 0:00:00 | ERNSH | Kirchgasse 6 |
| 11073 | 1998/5/5 0:00:00 | PERIC | Calle Dr. Jorge Cash 321 |
| 11074 | 1998/5/6 0:00:00 | SIMOB | Vinbæltet 34 |
| 11075 | 1998/5/6 0:00:00 | RICSU | Starenweg 5 |
| 11076 | 1998/5/6 0:00:00 | BONAP | 12, rue des Bouchers |
| 11077 | 1998/5/6 0:00:00 | RATTC | 2817 Milton Dr. |
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<PagedList<Order>>" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc"%>
<%@ Import Namespace="MvcPagerSample.Models"%>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
MvcPager 标准Url分页示例
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h1>MvcPager 标准Url分页示例</h1>
<table width="98%">
<tr><th>订单编号</th><th>订单日期</th><th>顾客编号</th><th>收货地址</th></tr>
<%foreach(Order 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" })%>
</asp:Content>
public ActionResult Index(int? id)
{
using (var db = new MvcPagerSampleDataContext())
{
PagedList<Order> orders = db.Orders.ToPagedList(id ?? 1, 20);
return View(orders);
}
}
