Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Invalid CurrentPageIndex Value

Reply
Thread Tools

Invalid CurrentPageIndex Value

 
 
Doug Holland
Guest
Posts: n/a
 
      01-26-2004
Hi Ther

I have a DataGrid on a webform which is causing an HttpException in the following code when it transitions from showing all of the packages in the system (12 on two pages) to only linked packages (3 on one page)

m_DataGrid.DataSource = _list; // _list is an ArrayList instanc

if(m_DataGrid.CurrentPageIndex > m_DataGrid.PageCount

m_DataGrid.CurrentPageIndex = 0


m_DataGrid.DataBind()

The if statement never evaluates to true and as such the CurrentPageIndex is not reset to zero at this point and therefore an appropriate value for CurrentPageIndex exists just prior to the call to m_DataGrid.DataBind(), within that method call though the CurrentPageIndex becomes invalid and the HttpException is thrown

How do I handle this situation

Thanks in advanc

Doug Holland
 
Reply With Quote
 
 
 
 
Andre
Guest
Posts: n/a
 
      02-19-2004
Doug Holland <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Hi There

I ran into a similar message "Invalid CurrentPageIndex value. It must
be >= 0 and < the PageCount." under the same circumstances.

It turned out that I was making multiple trips to the database from
separate subroutines: the first time to initially bind data to the
datagrid and then every time my CurrentIndexChanged subroutine ran. I
had declared the dataset separately in each subroutine, I don't think
the event handler liked this very much.

My (successful) solution was to declare the dataset as a protected
object for the class, then reference the same dataset table instance
from both subroutines. It eliminated this error, and reduced calls to
the database.




>
> I have a DataGrid on a webform which is causing an HttpException in the following code when it transitions from showing all of the packages in the system (12 on two pages) to only linked packages (3 on one page):
>
> m_DataGrid.DataSource = _list; // _list is an ArrayList instance
>
> if(m_DataGrid.CurrentPageIndex > m_DataGrid.PageCount)
> {
> m_DataGrid.CurrentPageIndex = 0;
> }
>
> m_DataGrid.DataBind();
>
> The if statement never evaluates to true and as such the CurrentPageIndex is not reset to zero at this point and therefore an appropriate value for CurrentPageIndex exists just prior to the call to m_DataGrid.DataBind(), within that method call though the CurrentPageIndex becomes invalid and the HttpException is thrown.
>
> How do I handle this situation?
>
> Thanks in advance
>
> Doug Holland

 
Reply With Quote
 
 
 
 
Andre
Guest
Posts: n/a
 
      02-19-2004
Also, on second review, I don't see where your datasource,

e.g. dgMyGrid.DataSource = ds.Tables["MyDataSetTable"];
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount in asp.net yakoobismail Software 0 05-22-2009 05:24 AM
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. Franck ASP .Net 4 06-29-2007 04:22 AM
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. George Smith ASP .Net 2 04-27-2007 12:05 AM
strange Invalid CurrentPageIndex value Daniel Bauke ASP .Net Datagrid Control 3 11-18-2003 01:13 AM
Invalid CurrentPageIndex value jm ASP .Net 0 10-30-2003 10:42 PM



Advertisments