MvcPager分页控件
标准Url分页示例
插入分页控件代码:
<%=Html.Pager(Model,new PagerOptions{PageIndexParameterName="id"}) %>
| 订单编号 | 订单日期 | 顾客编号 | 收货地址 |
|---|---|---|---|
| 11020 | 1998/4/14 0:00:00 | OTTIK | Mehrheimerstr. 369 |
| 11021 | 1998/4/14 0:00:00 | QUICK | Taucherstraße 10 |
| 11022 | 1998/4/14 0:00:00 | HANAR | Rua do Paço, 67 |
| 11023 | 1998/4/14 0:00:00 | BSBEV | Fauntleroy Circus |
| 11024 | 1998/4/15 0:00:00 | EASTC | 35 King George |
| 11025 | 1998/4/15 0:00:00 | WARTH | Torikatu 38 |
| 11026 | 1998/4/15 0:00:00 | FRANS | Via Monte Bianco 34 |
| 11027 | 1998/4/16 0:00:00 | BOTTM | 23 Tsawassen Blvd. |
| 11028 | 1998/4/16 0:00:00 | KOENE | Maubelstr. 90 |
| 11029 | 1998/4/16 0:00:00 | CHOPS | Hauptstr. 31 |
| 11030 | 1998/4/17 0:00:00 | SAVEA | 187 Suffolk Ln. |
| 11031 | 1998/4/17 0:00:00 | SAVEA | 187 Suffolk Ln. |
| 11032 | 1998/4/17 0:00:00 | WHITC | 1029 - 12th Ave. S. |
| 11033 | 1998/4/17 0:00:00 | RICSU | Starenweg 5 |
| 11034 | 1998/4/20 0:00:00 | OLDWO | 2743 Bering St. |
| 11035 | 1998/4/20 0:00:00 | SUPRD | Boulevard Tirou, 255 |
| 11036 | 1998/4/20 0:00:00 | DRACD | Walserweg 21 |
| 11037 | 1998/4/21 0:00:00 | GODOS | C/ Romero, 33 |
| 11038 | 1998/4/21 0:00:00 | SUPRD | Boulevard Tirou, 255 |
| 11039 | 1998/4/21 0:00:00 | LINOD | Ave. 5 de Mayo Porlamar |
<%@ 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);
}
}
