Search code examples
eventsgridviewpage-index-changed

event PageIndexChanging wasn't handled


I'm getting "The GridView 'grdFiles' fired event PageIndexChanging which wasn't handled." even if I've added the event handler:

protected void grdFiles_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GetFiles();
        grdFiles.PageIndex = e.NewPageIndex;
        grdFiles.DataBind();

    }

Any ideas?


Solution

  • Try this code. You need to declare a method on your code behind that handles the PageIndexChanging event.

    protected void grdFiles_PageIndexChanging (object sender, GridViewPageEventArgs  e)
    {
    grdFiles.PageIndex = e.NewPageIndex;
    bindGridView()
    }
    

    the method bindGridView() is

    private void bindGridView()
    {
     grdFiles.DataSource=.....;
     grdFiles.DataBind();
    }