Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Invalid CurrentPageIndex value. It must be >= 0 and < the PageCoun

Reply
Thread Tools

Invalid CurrentPageIndex value. It must be >= 0 and < the PageCoun

 
 
Juan G.
Guest
Posts: n/a
 
      07-06-2005
I have a DataGrid in which I use paging, as well as Delete buttons. My
program works perfectly, except when I attempt to delete the only item on the
page; I have no trouble deleting an item when there are more than one item
on a page. For example, I have a list that is three pages long; there is
currently only one item on page 3. I receive the above error message when I
try to delete this item. Do I need to include a special line of code to
prevent this from happening?
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-06-2005
Hi,

yes, it needs to be handled manually
http://forums.asp.net/798105/ShowPost.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


 
Reply With Quote
 
 
 
 
Juan G.
Guest
Posts: n/a
 
      07-06-2005
Thank you, Teemu. I read this thread, and I think I might understand. I code
in VB.Net, so the C# answer was a little confusing. They mentioned this code:

if ((DataGrid.Items.Count % DataGrid.PageSize) == 1
&& DataGrid.CurrentPageIndex != 0 )
DataGrid.CurrentPageIndex = DataGrid.PageCount - 2;

Would it be correct to translate this as:

If (DataGrid.Items.Count OR DataGrid.PageSize = 1
AND DataGrid.CurrentPageIndex NotEqual 0 ) Then
DataGrid.CurrentPageIndex = DataGrid.PageCount - 2

Also, do I place this command at the beginning of my Delete Row sub (BEFORE
I delete the row)?

Thanks again for your help.

Juan G.

"Teemu Keiski" wrote:

> Hi,
>
> yes, it needs to be handled manually
> http://forums.asp.net/798105/ShowPost.aspx
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
>

 
Reply With Quote
 
Juan G.
Guest
Posts: n/a
 
      07-06-2005
I just did some research, and I think the correct VB.NET syntax would be:

If ((Math.IEEERemainder(DataGrid.Items.Count, DataGrid.PageSize)=1) AndAlso
(DataGrid.CurrentPageIndex <>0)) Then DataGrid.CurrentPageIndex =
DataGrid.PageCount-2

End If

"Teemu Keiski" wrote:

> Hi,
>
> yes, it needs to be handled manually
> http://forums.asp.net/798105/ShowPost.aspx
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
>

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      07-12-2005
Hello,

it's crucial that you just have correct CurrentPageIndex when the grid is
rebound again. So, if deleting would fail then you wouldn't change the
index, but if it succeeds and you rebind the list, then you'd want to
correct the index.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      07-12-2005
And by the way

if ((DataGrid.Items.Count % DataGrid.PageSize) == 1

means modulus e.g

If (DataGrid.Items.Count Mod DataGrid.PageSize) = 1

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke





 
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
"Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount." Franck ASP .Net Datagrid Control 0 10-21-2005 08:04 AM
Invalid CurrentPageIndex value jm ASP .Net 0 10-30-2003 10:42 PM



Advertisments