How to do Paging in VB.NET

Hello Guys,

I want to add paging like that of ‘http://www.alligatorsoup.com/cart/search.asp’ to my web site
http://www.thanksdarling.com’.

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.

Hi

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
dl.DataBind()

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

like:
.AllowPaging(Boolean)
.PageSize
.CurrentPageIndex
.Count
.PageCount
.IsFirstPage (Boolean)
.IsLastPage(Boolean)

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

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

Cheers,
Rui