MvcPager分页控件
标准Url分页示例
插入分页控件代码:
<%=Html.Pager(Model,new PagerOptions{PageIndexParameterName="id"}) %>
| 订单编号 | 订单日期 | 顾客编号 | 收货地址 |
|---|---|---|---|
| 10780 | 1997/12/16 0:00:00 | LILAS | Carrera 52 con Ave. Bolívar #65-98 Llano Largo |
| 10781 | 1997/12/17 0:00:00 | WARTH | Torikatu 38 |
| 10782 | 1997/12/17 0:00:00 | CACTU | Cerrito 333 |
| 10783 | 1997/12/18 0:00:00 | HANAR | Rua do Paço, 67 |
| 10784 | 1997/12/18 0:00:00 | MAGAA | Via Ludovico il Moro 22 |
| 10785 | 1997/12/18 0:00:00 | GROSR | 5ª Ave. Los Palos Grandes |
| 10786 | 1997/12/19 0:00:00 | QUEEN | Alameda dos Canàrios, 891 |
| 10787 | 1997/12/19 0:00:00 | LAMAI | 1 rue Alsace-Lorraine |
| 10788 | 1997/12/22 0:00:00 | QUICK | Taucherstraße 10 |
| 10789 | 1997/12/22 0:00:00 | FOLIG | 184, chaussée de Tournai |
| 10790 | 1997/12/22 0:00:00 | GOURL | Av. Brasil, 442 |
| 10791 | 1997/12/23 0:00:00 | FRANK | Berliner Platz 43 |
| 10792 | 1997/12/23 0:00:00 | WOLZA | ul. Filtrowa 68 |
| 10793 | 1997/12/24 0:00:00 | AROUT | Brook Farm Stratford St. Mary |
| 10794 | 1997/12/24 0:00:00 | QUEDE | Rua da Panificadora, 12 |
| 10795 | 1997/12/24 0:00:00 | ERNSH | Kirchgasse 6 |
| 10796 | 1997/12/25 0:00:00 | HILAA | Carrera 22 con Ave. Carlos Soublette #8-35 |
| 10797 | 1997/12/25 0:00:00 | DRACD | Walserweg 21 |
| 10798 | 1997/12/26 0:00:00 | ISLAT | Garden House Crowther Way |
| 10799 | 1997/12/26 0:00:00 | KOENE | Maubelstr. 90 |
<%@ 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);
}
}
