Fork me on GitHub

PageChanged 事件

分页控件所在的页面重新加载且没有回发时发生。

C# 语法:

public event EventHandler PageChanged;

示例:

以下示例演示如何编写 PageChanged事件并在事件处理程序中绑定数据:
    <webdiyer:UrlPager runat="server" id="pager1" RouteName="UrlPager_Repeater" 
    CssClass="pull-right" PageIndexParameterName="id" PagerItemTemplate="&nbsp;{0}" 
    OnPageChanged="PageChanged"></webdiyer:UrlPager> 


    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();
        }
    }