How to do Paging in VB.NET

Hello Guys,

I want to add paging like that of ‘’ to my web site’.

I want help so that i can use previous, next hyperlinks, with current page out of total number of pages = total records / Page size and also a text box where my web site user can insert directly page number he wish to go.


You can use the PagedDataSource Class to build something like that.
Search in the Sitepoint Articles theres a nice article about paging DataSources.

You can pass a Table or DataView from a DataSet to PagedDataSource and then bind it to a DataList.

Dim objDV as DataView
Dim PagedData As PagedDataSource
Dim dl as DataList

PagedData.DataSource = objDV
dl.DataSource = PagedData

PagedDataSource has several properties that you can use to build the paging links.

.IsFirstPage (Boolean)

For the Label " Page 1 of 30 " you could have something like

lblPages.Text = PagedData.CurrentPageIndex & " to " & PagedData.PageCount