- 基本功能
- 分页按钮属性效果
- 使用自定义信息区
- Repeater分页
- DataList分页
- Url分页
- Url重写
- Url逆向分页
- n层结构应用
- 使用Xml文件数据源
- 图片浏览示例
- AccessDataSource分页
- SqlDataSource分页
- ObjectDataSource分页
- 自定义数据呈现逻辑
- 使用图片按钮
- 查询结果分页
- 查询结果Url分页
- 克隆属性及事件
- 页索引输入/选择框
- 自定义导航按钮
- 在用户控件中实现分页
- UpdatePanel支持
- 设置当前页按钮位置
- 使用Table布局
- 自定义提交按钮图片
- 从Url中获取每页显示记录数
- 应用CSS样式
- 使用GoToPage方法
- 分页导航元素布局
- 类:
- 属性:
- AlwaysShow
- AlwaysShowFirstLastPageNumber
- BackImageUrl
- ButtonImageAlign
- ButtonImageExtension
- ButtonImageNameExtension
- CloneFrom
- CpiButtonImageNameExtension
- CssClass
- CurrentPageButtonClass
- CurrentPageButtonPosition
- CurrentPageButtonStyle
- CurrentPageButtonTextFormatString
- CurrentPageIndex
- CustomInfoClass
- CustomInfoHTML
- CustomInfoSectionWidth
- CustomInfoStyle
- CustomInfoTextAlign
- DisabledButtonImageNameExtension
- EnableTheming
- EnableUrlRewriting
- EndRecordIndex
- FirstPageText
- FirstPageUrlRewritePattern
- HorizontalAlign
- ImagePath
- InvalidPageIndexErrorMessage
- LastPageText
- LayoutType
- MoreButtonType
- NavigationButtonsPosition
- NavigationButtonType
- NavigationToolTipTextFormatString
- NextPageText
- NumericButtonCount
- NumericButtonTextFormatString
- NumericButtonType
- PageCount
- PageIndexBoxClass
- PageIndexBoxStyle
- PageIndexBoxType
- PageIndexOutOfRangeErrorMessage
- PageSize
- PagesRemain
- PagingButtonLayoutType
- PagingButtonSpacing
- PagingButtonType
- PrevPageText
- RecordCount
- RecordsRemain
- ReverseUrlPageIndex
- ShowBoxThreshold
- ShowCustomInfoSection
- ShowDisabledButtons
- ShowFirstLast
- ShowMoreButtons
- ShowNavigationToolTip
- ShowPageIndex
- ShowPageIndexBox
- ShowPrevNext
- SkinID
- StartRecordIndex
- SubmitButtonClass
- SubmitButtonImageUrl
- SubmitButtonStyle
- SubmitButtonText
- TextAfterPageIndexBox
- TextBeforePageIndexBox
- UrlPageIndexName
- UrlPageSizeName
- UrlPaging
- UrlPagingTarget
- UrlRewritePattern
- 方法:
- 事件:
- 枚举:
- 委托:
PageChanged 事件
C# 语法:
public event EventHandler PageChanged;
备注:
该事件被引发时,AspNetPager 已完成分页操作。示例:
下面的示例显示如何为PageChanged事件指定和编写事件处理程序,在该事件处理程序中重新绑定Repeater上显示的数据: <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> <%@Import NameSpace="System.Data"%> <%@Import NameSpace="System.Data.SqlClient"%> <script runat="server" Language="C#"> void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int totalOrders = (int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "P_GetOrderNumber"); AspNetPager1.RecordCount = totalOrders; bindData(); } } void bindData() { Repeater1.DataSource = SqlHelper.ExecuteReader(CommandType.StoredProcedure,"P_GetPagedOrders2005", new SqlParameter("@startIndex", AspNetPager1.StartRecordIndex), new SqlParameter("@pageSize", AspNetPager1.PageSize)); Repeater1.DataBind(); } void AspNetPager1_PageChanged(object src, EventArgs e) { bindData(); } </script> <HTML><HEAD> <TITLE> AspNetPager Samples </TITLE> <META NAME="Author" CONTENT="Webdiyer (www.webdiyer.com)"> </HEAD> <BODY> <form runat="server"> <webdiyer:AspNetPager ID="AspNetPager1" runat="server" Width="100%" HorizontalAlign="right" PageSize="8" OnPageChanged="AspNetPager1_PageChanged"> </webdiyer:AspNetPager> <asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <table width="100%" border="1" cellspacing="0" cellpadding="4" style="border-collapse:collapse"> <tr style="backGround-color:#CCCCFF"><th style="width:15%"><asp:Literal ID="Literal1" runat="server" Text="<%$Resources:LocalizedText,orderid%>" /></th><th style="width:15%"><asp:Literal ID="Literal3" runat="server" Text="<%$Resources:LocalizedText,orderdate%>" /></th><th style="width:30%"><asp:Literal ID="Literal5" runat="server" Text="<%$Resources:LocalizedText,companyname%>" /></th><th style="width:20%"><asp:Literal ID="Literal2" runat="server" Text="<%$Resources:LocalizedText,customerid%>" /></th><th style="width:20%"><asp:Literal ID="Literal4" runat="server" Text="<%$Resources:LocalizedText,employeename%>" /></th></tr> </HeaderTemplate> <ItemTemplate> <tr style="background-color:#FAF3DC"> <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:AspNetPager ID="AspNetPager2" runat="server" CloneFrom="AspNetPager1"> </webdiyer:AspNetPager> </form> </BODY> </HTML>
该示例所用的Sql Server存储过程代码如下(仅适用于SQL Server 2005):
CREATE PROCEDURE P_GetPagedOrders2005 @startIndex INT, @pageSize INT AS begin WITH orderList AS ( SELECT ROW_NUMBER() OVER (ORDER BY O.orderid DESC)AS Row, O.orderid,O.orderdate,O.customerid,C.CompanyName,E.FirstName+' '+E.LastName as EmployeeName from orders O left outer join Customers C on O.CustomerID=C.CustomerID left outer join Employees E on O.EmployeeID=E.EmployeeID) SELECT orderid,orderdate,customerid,companyName,employeeName FROM orderlist WHERE Row between @startIndex and @startIndex+@pageSize-1 end