paging problem

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

Why would this not work?
//
Private Sub nNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles nNext.Click
dgTopTen.CurrentPageIndex += 1
dgTopTen.DataBind()
End Sub
\\

I get this error message here: Invalid CurrentPageIndex value. It must be >=
0 and < the PageCount

I have also tried something like this:
//
Private Sub dgHistory_PageIndexChanged(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dgHistory.PageIndexChanged
dgTopTen.CurrentPageIndex = e.NewPageIndex
dgTopTen.DataBind()
End Sub
\\

With this one my first 5 records are still shown.

I am all new to this so I appreciate and thank you for the help in what I am
missing.

Brad
 
Hi Brad,

In order to page, you need re-bind datagrid's data source:

dgTopTen.CurrentPageIndex = e.NewPageIndex
dgTopTen.DataSource = GetDataSource ' Get data source from
Session or db
dgTopTen.DataBind()

HTH

Elton Wang
(e-mail address removed)
 
Back
Top