MvcPager分页控件
标准Url分页示例
插入分页控件代码:
<%=Html.Pager(Model,new PagerOptions{PageIndexParameterName="id"}) %>
| 订单编号 | 订单日期 | 顾客编号 | 收货地址 |
|---|---|---|---|
| 10920 | 1998/3/3 0:00:00 | AROUT | Brook Farm Stratford St. Mary |
| 10921 | 1998/3/3 0:00:00 | VAFFE | Smagsloget 45 |
| 10922 | 1998/3/3 0:00:00 | HANAR | Rua do Paço, 67 |
| 10923 | 1998/3/3 0:00:00 | LAMAI | 1 rue Alsace-Lorraine |
| 10924 | 1998/3/4 0:00:00 | BERGS | Berguvsvägen 8 |
| 10925 | 1998/3/4 0:00:00 | HANAR | Rua do Paço, 67 |
| 10926 | 1998/3/4 0:00:00 | ANATR | Avda. de la Constitución 2222 |
| 10927 | 1998/3/5 0:00:00 | LACOR | 67, avenue de l'Europe |
| 10928 | 1998/3/5 0:00:00 | GALED | Rambla de Cataluña, 23 |
| 10929 | 1998/3/5 0:00:00 | FRANK | Berliner Platz 43 |
| 10930 | 1998/3/6 0:00:00 | SUPRD | Boulevard Tirou, 255 |
| 10931 | 1998/3/6 0:00:00 | RICSU | Starenweg 5 |
| 10932 | 1998/3/6 0:00:00 | BONAP | 12, rue des Bouchers |
| 10933 | 1998/3/6 0:00:00 | ISLAT | Garden House Crowther Way |
| 10934 | 1998/3/9 0:00:00 | LEHMS | Magazinweg 7 |
| 10935 | 1998/3/9 0:00:00 | WELLI | Rua do Mercado, 12 |
| 10936 | 1998/3/9 0:00:00 | GREAL | 2732 Baker Blvd. |
| 10937 | 1998/3/10 0:00:00 | CACTU | Cerrito 333 |
| 10938 | 1998/3/10 0:00:00 | QUICK | Taucherstraße 10 |
| 10939 | 1998/3/10 0:00:00 | MAGAA | Via Ludovico il Moro 22 |
<%@ 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);
}
}
