Datagrid Paging Not Displayinig Correct Page

Discussion in 'ASP .Net Datagrid Control' started by Chris Lee, Sep 9, 2003.

  1. Chris Lee

    Chris Lee Guest

    Hello All,

    I'm having a problem with datagrid paging. I've got a datagrid with CustomPaging=True.

    Here are the symptoms of the problem:

    1. When first displaying the data for the datagrid, the first page is displayed no matter what value has been assigned to CurrentPageIndex property.

    2. When going to "Page 2", the datagrid still displays data for page 1, but the number 2 is "disabled" in the paging number at the bottom of the datagrid.

    3. When going to "Page 3", the datagrid displays data for page 2, but the number 3 is "disabled". After this point, the data that is displayed in the datagrid is always from the previous page index that the user selected.

    4. When walking through the code, the values for datagrid.CurrentPageIndex and e.NewPageIndex are correct. Just before the event for the PageIndexChanged has ended, the values of the CurrentPageIndex are correct (despite the wrong data is displayed).

    Any help would be greatly appreciated,
    Chris

    Below are snipets of the code that I'm using

    Public Sub MSDReferenceSummary_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
    On Error GoTo MSDReferenceSummary_PageIndexChanged_Err

    DataGrid_Summ_PageIndexChanged(MSDReference_Summary_DG, source, e)

    MSDReference_Summary_DG.DataBind()

    MSDReferenceSummary_PageIndexChanged_Exit:

    On Error Resume Next

    Exit Sub

    MSDReferenceSummary_PageIndexChanged_Err:

    Handle_Page_Error("MSDReferenceSummary_PageIndexChanged Error: " & Err.Description)

    Resume MSDReferenceSummary_PageIndexChanged_Exit

    End Sub



    Public Sub DataGrid_Summ_PageIndexChanged(ByRef dgDataGrid As DataGrid, ByRef source As Object, ByRef e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)

    On Error GoTo DataGrid_Summ_PageIndexChanged_Err

    Dim objUserInfo As udtUserInfo

    Dim objDataGridInfo() As udtDataGridInfo

    Dim dsFormData As DataSet

    Dim strSQLOrderBy As String

    Dim lngDataGridNum As Long

    objUserInfo = Session.Item("objUserInfo")

    objDataGridInfo = Session.Item("objDataGridInfo")

    'Code sniped out, basically code to retrieve the data for the dataset

    With objDataGridInfo(lngDataGridNum)

    ..lngRecordPosition = Record_Page_Position(objUserInfo.intSummaryPageSize, CLng(e.NewPageIndex))

    ..dvDataView = dsFormData.Tables(0).DefaultView

    End With

    Session.Item("objDataGridInfo") = objDataGridInfo

    'This is where the Current Page index is set, and the datasource

    'is bound to the datagrid

    With dgDataGrid

    ..CurrentPageIndex = e.NewPageIndex

    ..DataSource = objDataGridInfo(lngDataGridNum).dvDataView

    ..DataBind()

    End With

    Session.Item("objDataGridInfo") = objDataGridInfo

    Session.Item("dsFormData") = dsFormData

    DataGrid_Summ_PageIndexChanged_Exit:

    On Error Resume Next

    Exit Sub

    DataGrid_Summ_PageIndexChanged_Err:

    Handle_Page_Error("DataGrid_Summ_PageIndexChanged Error: " & Err.Description)

    Resume DataGrid_Summ_PageIndexChanged_Exit

    End Sub
     
    Chris Lee, Sep 9, 2003
    #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. wh1974
    Replies:
    0
    Views:
    2,439
    wh1974
    Jan 12, 2005
  2. Red
    Replies:
    1
    Views:
    724
  3. Shapper
    Replies:
    2
    Views:
    602
    Guest
    Jun 22, 2005
  4. Dan

    correct or not correct?

    Dan, Oct 2, 2003, in forum: HTML
    Replies:
    7
    Views:
    445
  5. J.Ram
    Replies:
    7
    Views:
    654
Loading...

Share This Page