Gridview page not change on first click

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
 
P

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top