MvcPager分页控件
ASP.NET MVC Pager 分页控件用户自定义信息示例
| 订单编号 | 订单日期 | 顾客编号 | 收货地址 |
|---|---|---|---|
| 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">
用户自定义信息
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>ASP.NET MVC Pager 分页控件用户自定义信息示例</h2>
<div>本示例演示如何获取和显示相关分页信息。</div>
<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>
<div class="clear"><span style="float:left;width:40%">共<%=Model.TotalItemCount %>条记录,
页<%=Model.CurrentPageIndex %>/<%=Model.TotalPageCount %></span>
<%=Html.Pager(Model,new PagerOptions{ContainerTagName="span",
PageIndexParameterName="id",AlwaysShowFirstLastPageNumber = true,
HorizontalAlign="right"},new{Style="float:right;width:60%"}) %></div>
</asp:Content>
public ActionResult CustomInfo(int? id)
{
using (var db = new MvcPagerSampleDataContext())
{
PagedList<Order> orders = db.Orders.ToPagedList(id ?? 1, 20);
return View(orders);
}
}
