MvcPager分页控件
标准Url分页示例
插入分页控件代码:
<%=Html.Pager(Model,new PagerOptions{PageIndexParameterName="id"}) %>
| 订单编号 | 订单日期 | 顾客编号 | 收货地址 |
|---|---|---|---|
| 10900 | 1998/2/20 0:00:00 | WELLI | Rua do Mercado, 12 |
| 10901 | 1998/2/23 0:00:00 | HILAA | Carrera 22 con Ave. Carlos Soublette #8-35 |
| 10902 | 1998/2/23 0:00:00 | FOLKO | Åkergatan 24 |
| 10903 | 1998/2/24 0:00:00 | HANAR | Rua do Paço, 67 |
| 10904 | 1998/2/24 0:00:00 | WHITC | 1029 - 12th Ave. S. |
| 10905 | 1998/2/24 0:00:00 | WELLI | Rua do Mercado, 12 |
| 10906 | 1998/2/25 0:00:00 | WOLZA | ul. Filtrowa 68 |
| 10907 | 1998/2/25 0:00:00 | SPECD | 25, rue Lauriston |
| 10908 | 1998/2/26 0:00:00 | REGGC | Strada Provinciale 124 |
| 10909 | 1998/2/26 0:00:00 | SANTG | Erling Skakkes gate 78 |
| 10910 | 1998/2/26 0:00:00 | WILMK | Keskuskatu 45 |
| 10911 | 1998/2/26 0:00:00 | GODOS | C/ Romero, 33 |
| 10912 | 1998/2/26 0:00:00 | HUNGO | 8 Johnstown Road |
| 10913 | 1998/2/26 0:00:00 | QUEEN | Alameda dos Canàrios, 891 |
| 10914 | 1998/2/27 0:00:00 | QUEEN | Alameda dos Canàrios, 891 |
| 10915 | 1998/2/27 0:00:00 | TORTU | Avda. Azteca 123 |
| 10916 | 1998/2/27 0:00:00 | RANCH | Av. del Libertador 900 |
| 10917 | 1998/3/2 0:00:00 | ROMEY | Gran Vía, 1 |
| 10918 | 1998/3/2 0:00:00 | BOTTM | 23 Tsawassen Blvd. |
| 10919 | 1998/3/2 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);
}
}
