Sunday, August 17, 2008

How to Solve this error "The GridView 'MyGridview' fired event PageIndexChanging which wasn't handled."

You can see this error when you are populating a Gridview with code, and you enabled the Paging Property of the Gridview without implementing the PageIndexChanging Event.

So when you click the next Page in the Gridview you will see this error:

"The GridView 'MyGridview' fired event PageIndexChanging which wasn't handled."

To avoid this issue simply write this code in the PageIndexChanging Event:
MyGridview.PageIndex = e.NewPageIndex;
MyGridview.DataBind();

2 comments:

  1. Thank's amr for this helpful snippet, it is really a cool, thanks alot :)

    ReplyDelete
  2. Thank you guru...really easy

    ReplyDelete