Grid Paging

Discussion in 'ASP .Net Datagrid Control' started by Red, Jul 2, 2004.

  1. Red

    Red Guest

    I am having trouble making the grid paging work. When I first come into the
    page the page count is 3. But when I click to go to page 2 and do the
    postback the number of pages become 1.

    Here is the code in the page load:

    'this calls the fill dataset method
    If Not IsPostBack Then
    FillMessagesGrid()
    End If

    Her is the FillMessageGrid Method:

    Private Sub FillMessagesGrid()
    'get the current dataset
    DsGetCurrentMessages1 =
    DirectCast(MessageServer.GetCurrentMessages().Copy,
    MessagingServices.dsGetCurrentMessages)

    'cache the dataset to a session variable
    Session("MessageCache") =
    DirectCast(Me.DsGetCurrentMessages1.Copy(),
    MessagingServices.dsGetCurrentMessages)

    'bind the grid to the cached dataset
    gridMessages.DataSource = DirectCast(Session("MessageCache"),
    MessagingServices.dsGetCurrentMessages)
    gridMessages.DataBind()
    End Sub

    This fills the grid and everything is fine:
    Here is my code in the PageIndexChanged Event Handler:

    Public Sub PageIndexChanged(ByVal sender As Object, ByVal e As
    DataGridPageChangedEventArgs) Handles gridMessages.PageIndexChanged
    Try
    gridMessages.CurrentPageIndex = e.NewPageIndex
    gridMessages.DataSource = DirectCast(Session("MessageCache"),
    MessagingServices.dsGetCurrentMessages)
    gridMessages.DataBind()
    Catch ex As Exception
    Session("CurrentErrorMessage") = gridMessages.PageCount
    Session("CurrentErrorPage") = "home.aspx"
    Server.Transfer("errorform.aspx")
    End Try
    End Sub

    Please help, this is driving me crazy.

    Thank in advance for any help.
    Red, Jul 2, 2004
    #1
    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:
    982
    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,681
    Scott Allen
    Oct 8, 2004
  4. wh1974
    Replies:
    0
    Views:
    2,428
    wh1974
    Jan 12, 2005
  5. Red
    Replies:
    1
    Views:
    714
Loading...

Share This Page