Grid Paging

R

Red

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.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top