Paging on Datagrid Does Not Work

B

Bruce LeMond

This is a Visual Basic web form. I set the datagrid
properties to allow for paging with 10 rows displayed per
page. When I run and click on the Next button (>), it
does not go to the next page. There are more than 10 rows
to be displayed. Anyone knows why this is not working?

Thanks in advance.
 
B

Bruce LeMond

I checked and the allowPaging is set to TRUE. But I
discovered that I needed to add this coding:

Private Sub DataGrid1_PageIndexChanged(ByVal source As
Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs)
Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub

But when I added this code and ran, I received this
following error message:

System.Web.HttpException: Invalid CurrentPageIndex value.
It must be >= 0 and < the PageCount.

Could you think of anything else?

Thanks,
Bruce
 
S

Slawek

Hi,
I think that you should check when you fill dataset because exception that
you receive means that there is no second page in dataset (there is less
then 10 rows). When you open page for the first time - there is more then 10
rows (becouse next button appear), but click on the "next" link to reloads
page and probably after reload you don't fill dataset.
Check if there is no code like this :
if(! IsPostback)
{
//fill of your dataset
}

I think that this is your problem

Regards
Slawek
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top