PageIndexChanging in GridView in ASP.NET

JCTLK picture JCTLK · Jan 12, 2011 · Viewed 96.8k times · Source

I have a gridview which I am using to display a dataset result. The problem is I am using paging in it. But when I click on the page # it says that I haven't handled the event. Do I need to rebind the dataset???

Thanks

Answer

KGWR picture KGWR · Jan 12, 2011

Try the following code:

protected void grdView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    FillGrid();
    grdView.PageIndex = e.NewPageIndex;
    grdView.DataBind();
}