unexpected behavior in Datagrid paging : PLEASE HELP >: (

J

Juan Romero

Hi guys,

Background:
I have a grid that is bound to a table in a dataset. On first load the
command of the SQLAdapter is configured to get all the records. I also have
a calendar control on the page that changes the SQLAdapter's select command
based on the date range the user selects on the calendar, and rebinds the
datagrid.
When I change the date, the datagrid is refreshed with the new data (new
round trip) and it displays records accordingly. Paging is set to 20 records
per page. I get the value of the recordcount, and it has for example 25
records (2 pages). The link for next page is active since there are 2 pages,
so everything looks fine up to that.

The Problem:
When I click on the "Next page" link of the datagrid, I get the following
error:
"pageindex must be > -1 and < PageCount"

WHY IS THIS HAPPENING?

I mean, the dataset has enough rows for 2 pages, which is why the datagrid
displays the next page link, but when my code tries to set the pageindex
property it gives me this error.

I must also mention that when the grid loads by default the first time with
all the records, the code that changes the pageindex property works fine, no
errors. It is only happening after I change the data to be loaded.

I know I must be missing something, please help. This is a time sensitive
project.

Thanks in advance!
 
A

Alvin Bruney

I've posted elsewhere long ago that i believe this to be a bug. you can work
around this by catching the error and resetting the pageindex = 0

it is happening because the pageindex and the item collection for the page
become out of sync basically
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top