Gridview page not change on first click

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi

I have a gridview which has allowpaging enabled, but when I click the page number for the first time, the page fire the
OnPageIndexChanging event and I checked the PageIndex has been updated in the event but my gridview doesn't reflect the new page
contents until the second click. The following Page Index was recorded in the OnPageIndexChanging event before and after
re-assigning the PageIndex of the gridview

First Click
0 (Original page index) --> 1 (Incresed to 1) but the grid does not change.

Second Click
1-->1 (Grid changed)

Does anyone know what went wrong ?

Thanks
Peter
 
I have tried adding a line in my Page_Load after the databind but it doesn't help at all on showing the last page of the datasource
when the page load for the first time.

void Page_Load(object sender, EventArgs e)
{
..
if (!IsPostBack)
{
..
myGridView.DataBind();
myGridView.PageIndex = myGridView.PageCount - 1;
..
}
}

Anyone has any ideas why the gridview is not showing the correct data for the current PageIndex ?

Thanks
Peter
 
Back
Top