mobile ads

Wednesday 6 November 2013

PageIndexChanging Vs PageIndexChanged


PageIndexChanging
- Occurs when one of the pager buttons is clicked, but before the GridView control handles the paging operation. This event is often used to cancel the paging operation. 

Ex:
protected void gvTeachers_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            try
            {
                gvTeachers.PageIndex = e.NewPageIndex;
               //bind the grid
            }
            catch (Exception ex)
            {
                lblErrorMessage.Visible = true;
                lblErrorMessage.Text = ex.Message;
                log.Error(ex.Message + " "+ex.StackTrace);
            }
        }


PageIndexChanged
- Occurs when one of the pager buttons is clicked, but after the GridView control handles the paging operation. This event is commonly used when you need to perform a task after the user navigates to a different page in the control.

PageIndexChanged is fired after the actual page index is changed, but before the GridView is databound again with the new page data.

PageIndexChanging fired prior to the change and the PageIndexChanged fired after the new data for the next page is displayed. 

1 comments:

Er. Mohd Imran Ansari said...

Show the screenshort with example

Post a Comment