paging problem

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
 
E

Elton Wang

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)
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top