unexpected behavior in Datagrid paging : PLEASE HELP >: (

Discussion in 'ASP .Net Datagrid Control' started by Juan Romero, Sep 10, 2003.

  1. Juan Romero

    Juan Romero Guest

    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!
     
    Juan Romero, Sep 10, 2003
    #1
    1. Advertising

  2. Juan Romero

    Alvin Bruney Guest

    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
    "Juan Romero" <> wrote in message
    news:eA$...
    > 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!
    >
    >
     
    Alvin Bruney, Sep 11, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh1974
    Replies:
    0
    Views:
    2,482
    wh1974
    Jan 12, 2005
  2. G Dean Blake

    Unexpected datagrid behavior

    G Dean Blake, Jan 13, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    330
    G Dean Blake
    Jan 13, 2005
  3. Red
    Replies:
    1
    Views:
    766
  4. Replies:
    4
    Views:
    375
    Roland Pibinger
    Nov 10, 2006
  5. G Dean Blake

    unexpected datagrid behavior

    G Dean Blake, Jan 13, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    119
    G Dean Blake
    Jan 13, 2005
Loading...

Share This Page