- 类:
- 属性:
- AlwaysShowFirstLastPageNumber
- AutoHide
- ContainerTag
- CurrentPageIndex
- CurrentPageNumberFormatString
- CurrentPagerItemTemplate
- DisabledPagerItemTemplate
- EndItemIndex
- FirstPageText
- InheritsRouteValues
- LastPageText
- MorePagerItemTemplate
- MorePageText
- NavigationPagerItemTemplate
- NextPageText
- NumericPagerItemCount
- NumericPagerItemTemplate
- PageIndexParameterName
- PageNumberFormatString
- PagerItemTemplate
- PageSize
- PrevPageText
- ReversePageIndex
- RouteName
- RouteValues
- ShowDisabledPagerItems
- ShowFirstLast
- ShowMorePagerItems
- ShowNumericPagerItems
- ShowPrevNext
- StartItemIndex
- TotalItemCount
- TotalPageCount
- 方法:
- 事件:
UrlPager 示例 - Url逆向分页
本示例演示如何使用UrlPager分页控件进行逆向分页,逆向分页即Url中显示的页索引与实际页索引逆转。
Order ID | Order Date | Company Name | Customer ID | Employee Name |
---|---|---|---|---|
11057 | 1998/4/29 | North/South | NORTS | Janet Leverling |
11056 | 1998/4/28 | Eastern Connection | EASTC | Laura Callahan |
11055 | 1998/4/28 | HILARION-Abastos | HILAA | Robert King |
11054 | 1998/4/28 | Cactus Comidas para llevar | CACTU | Laura Callahan |
11053 | 1998/4/27 | Piccolo und mehr | PICCO | Andrew Fuller |
11052 | 1998/4/27 | Hanari Carnes | HANAR | Janet Leverling |
11051 | 1998/4/27 | La maison d'Asie | LAMAI | Robert King |
11050 | 1998/4/27 | Folk och fä HB | FOLKO | Laura Callahan |
11049 | 1998/4/24 | Gourmet Lanchonetes | GOURL | Janet Leverling |
11048 | 1998/4/24 | Bottom-Dollar Markets | BOTTM | Robert King |
路由定义:
routes.MapPageRoute("UrlPager_ReversePageIndex", "urlpager/demos/{controller}/{action}/{pageIndex}", "~/UrlPager/Demos/ReversePageIndex.aspx", false, new RouteValueDictionary { { "controller", "ReversePageIndex" }, { "action", "List" }, { "pageIndex", null } }, new RouteValueDictionary { { "controller", "ReversePageIndex" }, { "action", "List" } });
ReversePageIndex.aspx:
<%@Register Namespace="Webdiyer.WebControls" Assembly="Webdiyer.UrlPager" TagPrefix="webdiyer"%> <asp:Repeater ID="Repeater1" runat="server"> <headertemplate> <table class="table table-bordered table-hover"> <tr><th>Order ID</th><th>Order Date</th><th>Company Name</th><th>Customer ID</th><th>Employee Name</th></tr> </headertemplate> <itemtemplate> <tr> <td><%#DataBinder.Eval(Container.DataItem,"orderid")%></td> <td><%#DataBinder.Eval(Container.DataItem,"orderdate","{0:d}")%></td> <td><%#DataBinder.Eval(Container.DataItem, "companyname")%></td> <td><%#DataBinder.Eval(Container.DataItem,"customerid")%></td> <td><%#DataBinder.Eval(Container.DataItem,"employeename")%></td> </tr> </itemtemplate> <footertemplate> </table> </footertemplate> </asp:Repeater> <webdiyer:UrlPager runat="server" id="pager1" RouteName="UrlPager_ReversePageIndex" PagerItemTemplate=" {0}" ReversePageIndex="true" OnPageChanged="PageChanged"></webdiyer:UrlPager>
ReversePageIndex.aspx.cs:
using System; using System.Configuration; using System.Data; using System.Data.SqlClient; namespace Webdiyer.UrlPagerDemo { public partial class ReversePageIndex : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) pager1.TotalItemCount = (int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "P_GetOrderNumber"); } protected void PageChanged(object sender, EventArgs e) { Repeater1.DataSource = SqlHelper.ExecuteReader(CommandType.StoredProcedure, ConfigurationManager.AppSettings["pagedSPName"], new SqlParameter("@startIndex", pager1.StartItemIndex), new SqlParameter("@endIndex", pager1.EndItemIndex)); Repeater1.DataBind(); } } }