MvcPager分页控件
ASP.NET MVC Pager 分页控件用户自定义信息示例
| 订单编号 | 订单日期 | 顾客编号 | 收货地址 |
|---|---|---|---|
| 10820 | 1998/1/7 0:00:00 | RATTC | 2817 Milton Dr. |
| 10821 | 1998/1/8 0:00:00 | SPLIR | P.O. Box 555 |
| 10822 | 1998/1/8 0:00:00 | TRAIH | 722 DaVinci Blvd. |
| 10823 | 1998/1/9 0:00:00 | LILAS | Carrera 52 con Ave. Bolívar #65-98 Llano Largo |
| 10824 | 1998/1/9 0:00:00 | FOLKO | Åkergatan 24 |
| 10825 | 1998/1/9 0:00:00 | DRACD | Walserweg 21 |
| 10826 | 1998/1/12 0:00:00 | BLONP | 24, place Kléber |
| 10827 | 1998/1/12 0:00:00 | BONAP | 12, rue des Bouchers |
| 10828 | 1998/1/13 0:00:00 | RANCH | Av. del Libertador 900 |
| 10829 | 1998/1/13 0:00:00 | ISLAT | Garden House Crowther Way |
| 10830 | 1998/1/13 0:00:00 | TRADH | Av. Inês de Castro, 414 |
| 10831 | 1998/1/14 0:00:00 | SANTG | Erling Skakkes gate 78 |
| 10832 | 1998/1/14 0:00:00 | LAMAI | 1 rue Alsace-Lorraine |
| 10833 | 1998/1/15 0:00:00 | OTTIK | Mehrheimerstr. 369 |
| 10834 | 1998/1/15 0:00:00 | TRADH | Av. Inês de Castro, 414 |
| 10835 | 1998/1/15 0:00:00 | ALFKI | Obere Str. 57 |
| 10836 | 1998/1/16 0:00:00 | ERNSH | Kirchgasse 6 |
| 10837 | 1998/1/16 0:00:00 | BERGS | Berguvsvägen 8 |
| 10838 | 1998/1/19 0:00:00 | LINOD | Ave. 5 de Mayo Porlamar |
| 10839 | 1998/1/19 0:00:00 | TRADH | Av. Inês de Castro, 414 |
<%@ 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);
}
}
