Another Paging problem

V

Vince13

I'm fairly new to c# and Visual Studio. I've been having what seems like a
common paging problem. When I try to change pages (even just from the first
page to the second), the error comes up:

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

I have found many solutions on different websites, but they all have to do
with deleting entries on a page and then trying to use a CurrentPageIndex
larger than the PageCount. However, I have checked both of these variables
and they should be fine. I even added an if statement to guard against it
and the error still comes up.

if (DataGrid1.CurrentPageIndex >= 0 && DataGrid1.CurrentPageIndex <
DataGrid1.PageCount)
{
DataGrid1.DataBind();
}

If there is anyone who can give me any idea where to start to fix this
problem, I would greatly appriciate it.
 
V

Vince13

Sorry, I did set the CurrentPageIndex to e.NewPageIndex, I just didn't
include that code in the post. I'll repost on a ASP .NET group though.

Thanks
Vince,
this is an ASP.NET issue, not really a C# language one.

The ASP.NET group MS web interface:
http://msdn.microsoft.com/newsgroup....public.dotnet.framework.aspnet&lang=en&cr=US

You need to override the PageIndexChanged event and set the currentPageIndex
to the e.NewPageIndex there, before you re-bind your grid. Post on the
ASP.NET group if you still aren't sure.

Peter
I'm fairly new to c# and Visual Studio. I've been having what seems like a
common paging problem. When I try to change pages (even just from the first
[quoted text clipped - 16 lines]
If there is anyone who can give me any idea where to start to fix this
problem, I would greatly appriciate it.
 

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

Top