Forum Moderators: open

Message Too Old, No Replies

Invalid CurrentPageIndex value Error

Drop-Down + DataGrid Interaction

         

Argblat

2:21 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



Hi all, this question is for asp.net / c#

The page giving me the problem has a drop down box which (on auto postback) updates a datagrid based on a Form Variable.

The problem is caused when the drop-down returns an instance of the datagrid that has paging. If I click to the next page of that datagrid, and then use the drop down to select a different instance of the datagrid that does NOT have that second page (due to less records) I get the error, which reads:


Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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

How do I reset the CurrentPageIndex value on postback so that every autopostback returns the first page of that datagrid instance?

TheNige

7:58 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



yourdatagrid.currentpageindex = 0

that will set it back to the first page.

Argblat

5:50 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Thanks, that was exactly the solution I was looking for.

For anyone who stumbles upon this post as a solution to their problem, c# is very picky and requires the correct capitalization:

DataGrid1.CurrentPageIndex = 0;