Datagrid Paging Not Displayinig Correct Page

C

Chris Lee

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
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top