Grid Paging

Discussion in 'ASP .Net' started by Red, Jun 30, 2004.

  1. Red

    Red Guest

    I have implemented the PageIndexChanged event handler and also cached the
    data source to a session object. Everytime I click on the next page I get a:

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

    The page index is 1, the number of pages is 2. Any ideas?
    Red, Jun 30, 2004
    #1
    1. Advertising

  2. Red

    Red Guest

    OK, now I can get it to page, but there is no data. Now I know when the
    initial grid displays it shows 3 pages. I have cached the data to the cahe
    object. Here is the code from my PageIndexChanged event handler:

    #Region " Message Grid Page Index Changed Event Handler "

    Public Sub PageIndexChanged(ByVal sender As Object, ByVal e As
    DataGridPageChangedEventArgs) Handles gridMessages.PageIndexChanged

    Try

    gridMessages.CurrentPageIndex = e.NewPageIndex

    'gridMessages.DataSource = DirectCast(Cache.Get("MessageDataset"),
    MessagingServices.dsGetCurrentMessages)

    gridMessages.DataBind()

    Catch ex As Exception

    Session("CurrentErrorMessage") = gridMessages.PageCount

    Session("CurrentErrorPage") = "home.aspx"

    Server.Transfer("errorform.aspx")

    End Try

    End Sub

    #End Region

    "Red" <> wrote in message
    news:...
    > I have implemented the PageIndexChanged event handler and also cached the
    > data source to a session object. Everytime I click on the next page I get

    a:
    >
    > Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.
    >
    > The page index is 1, the number of pages is 2. Any ideas?
    >
    >
    Red, Jun 30, 2004
    #2
    1. Advertising

  3. Red

    JG Guest

    If you cache it in the session variable, you have to get it from session
    variable. You cannot get it from Cache object.

    "Red" <> wrote in message
    news:...
    > OK, now I can get it to page, but there is no data. Now I know when the
    > initial grid displays it shows 3 pages. I have cached the data to the cahe
    > object. Here is the code from my PageIndexChanged event handler:
    >
    > #Region " Message Grid Page Index Changed Event Handler "
    >
    > Public Sub PageIndexChanged(ByVal sender As Object, ByVal e As
    > DataGridPageChangedEventArgs) Handles gridMessages.PageIndexChanged
    >
    > Try
    >
    > gridMessages.CurrentPageIndex = e.NewPageIndex
    >
    > 'gridMessages.DataSource = DirectCast(Cache.Get("MessageDataset"),
    > MessagingServices.dsGetCurrentMessages)
    >
    > gridMessages.DataBind()
    >
    > Catch ex As Exception
    >
    > Session("CurrentErrorMessage") = gridMessages.PageCount
    >
    > Session("CurrentErrorPage") = "home.aspx"
    >
    > Server.Transfer("errorform.aspx")
    >
    > End Try
    >
    > End Sub
    >
    > #End Region
    >
    > "Red" <> wrote in message
    > news:...
    > > I have implemented the PageIndexChanged event handler and also cached

    the
    > > data source to a session object. Everytime I click on the next page I

    get
    > a:
    > >
    > > Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.
    > >
    > > The page index is 1, the number of pages is 2. Any ideas?
    > >
    > >

    >
    >
    JG, Jun 30, 2004
    #3
  4. Red

    William Guest

    I actually changed that so that it was saved to the cache object instead of
    the session object. As I said it pages but when it returns it has no data.
    Just so I understand when you page it IS doing a postback correct? This may
    be my issue.

    "JG" <> wrote in message
    news:3LpEc.613207$...
    > If you cache it in the session variable, you have to get it from session
    > variable. You cannot get it from Cache object.
    >
    > "Red" <> wrote in message
    > news:...
    > > OK, now I can get it to page, but there is no data. Now I know when the
    > > initial grid displays it shows 3 pages. I have cached the data to the

    cahe
    > > object. Here is the code from my PageIndexChanged event handler:
    > >
    > > #Region " Message Grid Page Index Changed Event Handler "
    > >
    > > Public Sub PageIndexChanged(ByVal sender As Object, ByVal e As
    > > DataGridPageChangedEventArgs) Handles gridMessages.PageIndexChanged
    > >
    > > Try
    > >
    > > gridMessages.CurrentPageIndex = e.NewPageIndex
    > >
    > > 'gridMessages.DataSource = DirectCast(Cache.Get("MessageDataset"),
    > > MessagingServices.dsGetCurrentMessages)
    > >
    > > gridMessages.DataBind()
    > >
    > > Catch ex As Exception
    > >
    > > Session("CurrentErrorMessage") = gridMessages.PageCount
    > >
    > > Session("CurrentErrorPage") = "home.aspx"
    > >
    > > Server.Transfer("errorform.aspx")
    > >
    > > End Try
    > >
    > > End Sub
    > >
    > > #End Region
    > >
    > > "Red" <> wrote in message
    > > news:...
    > > > I have implemented the PageIndexChanged event handler and also cached

    > the
    > > > data source to a session object. Everytime I click on the next page I

    > get
    > > a:
    > > >
    > > > Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.
    > > >
    > > > The page index is 1, the number of pages is 2. Any ideas?
    > > >
    > > >

    > >
    > >

    >
    >
    William, Jun 30, 2004
    #4
    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. Eddy Soeparmin
    Replies:
    1
    Views:
    800
    Alvin Bruney
    Jul 18, 2003
  2. Andrew Banks

    Paging of a data grid

    Andrew Banks, Apr 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    983
    Reva Baum
    Apr 2, 2004
  3. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,689
    Scott Allen
    Oct 8, 2004
  4. wh1974
    Replies:
    0
    Views:
    2,431
    wh1974
    Jan 12, 2005
  5. Red
    Replies:
    1
    Views:
    718
Loading...

Share This Page