Fork me on GitHub

PageChanged Event

Occurs when one of the pager buttons is clicked, but after the UrlPager control handles the paging operation.

C# Syntax:

public event EventHandler PageChanged;

Remarks:

This event occurs everytime page is loaded but not posted back.

Example:

The following example demonstrates how to write an event handler for the PageChanged event and binding data in the event handler:
        <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();
        }
    }