natsy problem with datagrid, paging and filters

B

branton ellerbee

Has anyone had this problem:

you are using a datagrid that is populated by a filter. Let say for
arguments sake, it is a list of clients. And you narrow the list with the
alphabet using a dropdown or textbox. Either one makes no difference in this
case.

So, you have a dropdown and you jump from "A" to "J", and it brings back all
of the clients whose names begin with "J". Let say it returns 15 pages of
clients that have the name "J". Let say you want someone on the 12th page,
so you navigate there. Everything is fine.

Then you need to go to the letter "B" next, so select "B" out of the
dropdown and you get this error:

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.


What is happening is that "B" doesn't have 15 pages of records, I realize
this. And because I was on page 12, there is no page 12 for the letter "B".
The recordset for "B" returns 6 pages of clients , etc...

To solve the problem, obviously, one needs to set the CurrentPageIndex = 0,
but this doesn't seem to work, and I don't know why. No matter where you try
to set the currentpageindex to zero, the datagrid seems to fire before that
code executes.

So does anyone know why this doesn't work and what needs to be done to fix
it?
 
G

Guest

Hi Branton:

You have to reset the data in your code before a selection is made -- i.e.,
right now you're "stuck" in J. You have to be able to access the whole DB
before you can filter again for "B." Off the top of my head, I don't know
how to code it, but that's the gist of what's happening.

Sandy
 

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

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,192
Latest member
KalaReid2

Latest Threads

Top