views:

25

answers:

1

Hi,

I have datagridview with paging enabled. But when I want to move from page to another page in the grid, then it only works when I press the 2nd time on some other page.

I read some on the internet that I need to bind the data of the gridview but the thing is, I cant bind the data again because the gridview was filled with data in the page_load from querystring and I dont really want to go over the querystring again in the PageIndexChanging function.

Here is the code:

protected void searchGridFA_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        searchGridFA.PageIndex = e.NewPageIndex;
}

So why does the page changes only from the 2nd time I press it?

Thanks!

Greg

A: 

You need to rebind your grid

protected void searchGridFA_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        searchGridFA.PageIndex = e.NewPageIndex;
        // rebind here
    }
TheGeekYouNeed