Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Invalid CurrentpageIndex

Author  Topic 

ChandanJ
Starting Member

6 Posts

Posted - 2007-10-29 : 13:55:22
Hi,
I'm having a search page which displays some records in a datagrid of page size 50. The records get displayed in 10 pages - 12345678910, suppose i clicked the 5 page and enter some search criteria, click on the Search button an error occured
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.

I tried to resolve this error by adding the following code, but it doesn't work
if(dgLegalDetails.Items.Count % dgLegalDetails.PageSize == 1)
{
if(dgLegalDetails.CurrentPageIndex <= dgLegalDetails.PageCount &&
dgLegalDetails.CurrentPageIndex != 0)
{
dgLegalDetails.CurrentPageIndex = dgLegalDetails.CurrentPageIndex -1;
}
}

Any help will be appreciated

ann
Posting Yak Master

220 Posts

Posted - 2007-11-07 : 17:05:53
you said in your example you click page 5 THEN enter a search criteria, when is the grid be loaded? After the page 5 click? If so, if your new criteria doesn't have a page 5, you will always throw an error
Go to Top of Page
   

- Advertisement -