views:

222

answers:

4

When trying to use the paging part of GridView in my application, I receive the following error:

The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.

A: 

It means that the dataset associated with the gridview doesn't support paging.

It doesn't mean that you can't paged with it. To do that you will need to write your own code in PageIndexChanging event.

eKek0
+2  A: 

You need to add an eventhandler to tell the GridView which page it should be looking at as I'm guessing you have done the .DataBind() in code. An example would be:

Markup:

<asp:GridView ID="GridView1" runat="server"
    EnablePagingAndSortingCallbacks="true"
    OnPageIndexChanged="GridView1_PageIndexChanged" />

Code:

    protected void GridView1_PageIndexChanged(object sender,
                                              GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }
Joe Swan
A: 

I mixed your answers and I get my answer. I solved this problem whit this code :

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    DataBind();
}
mohammad reza
A: 

For this type of problems one could use custom controls

YordanGeorgiev