Saturday, May 4, 2013

System.Web.HttpException in .NET GridView Control

Leave a Comment

Sometimes while using Grid View control and setting .net GridView AllowPaging property True and not handling the paging in code behind it throws exception  "System.Web.HttpException: The GridView fired event PageIndexChanging which wasn’t handled" as shown  in picture  below:
System.web.HttpException in Grid View

This exception can be handled on PageIndexChanging event of Grid View Control.

The code to solve this problem is given below:
protectedvoid grdstudent_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdstudent.PageIndex = e.NewPageIndex;
        Bind_Grid();
    }
Here grdstudent is the ID of the Grid View control. Change this one with your Grid View Id and Bind_Grid() method is used to Bind the grid view control with database. Replace this one with your method of binding the grid view control.
Hope this one sort out  your problem.


0 comments:

Post a Comment