- 类:
- 属性:
- 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 示例 - Repeater分页
本示例演示如何使用UrlPager分页控件对Repeater控件进行分页,使用的路由名为“UrlPager_Repeater”。
Order ID | Order Date | Company Name | Customer ID | Employee Name |
---|---|---|---|---|
10857 | 1998/1/28 | Berglunds snabbköp | BERGS | Laura Callahan |
10856 | 1998/1/28 | Antonio Moreno Taquería | ANTON | Janet Leverling |
10855 | 1998/1/27 | Old World Delicatessen | OLDWO | Janet Leverling |
10854 | 1998/1/27 | Ernst Handel | ERNSH | Janet Leverling |
10853 | 1998/1/27 | Blauer See Delikatessen | BLAUS | Anne Dodsworth |
10852 | 1998/1/26 | Rattlesnake Canyon Grocery | RATTC | Laura Callahan |
10851 | 1998/1/26 | Ricardo Adocicados | RICAR | Steven Buchanan |
10850 | 1998/1/23 | Victuailles en stock | VICTE | Nancy Davolio |
10849 | 1998/1/23 | Königlich Essen | KOENE | Anne Dodsworth |
10848 | 1998/1/23 | Consolidated Holdings | CONSH | Robert King |
路由定义:
routes.MapPageRoute("UrlPager_Repeater", "urlpager/demos/{controller}/{action}/{id}", "~/UrlPager/Demos/Repeater.aspx", false, new RouteValueDictionary { { "controller", "Repeater" }, { "action", "Page" }, { "id", null } }, new RouteValueDictionary { { "controller", "Repeater" }, { "action", "Page" } });
Repeater.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_Repeater" CssClass="pull-right" PageIndexParameterName="id" PagerItemTemplate=" {0}" OnPageChanged="PageChanged"></webdiyer:UrlPager>
Repeater.aspx.cs:
using System; using System.Configuration; using System.Data; using System.Data.SqlClient; namespace Webdiyer.UrlPagerDemo { public partial class Repeater : 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(); } } }