ASP 101 - Active Server Pages 101 db_paging.aspx
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="VB" runat="server">
	Sub Page_Load(sender as Object, e as EventArgs)
		If Not Page.IsPostBack Then
			ShowDataGrid()
		End If
	End Sub
	Sub ShowDataGrid()
		Dim objConnection As SqlConnection
		Dim objCommand    As SqlCommand
		Dim objAdapter    As SqlDataAdapter
		Dim objDataSet    As DataSet
		Dim strSQLQuery   As String
		' Set up our connection.
		objConnection = New SqlConnection("Data Source=10.2.2.133;" _
   & "Initial Catalog=samples;User Id=samples;Password=password;" _
   & "Connect Timeout=15;Network Library=dbmssocn;")
		' Set up our SQL query text.
		strSQLQuery = "SELECT * FROM sample"
		' Create new command object passing it our SQL query
		' and telling it which connection to use.
		objCommand = New SqlCommand(strSQLQuery, objConnection)
		' Get a DataSet to bind the DataGrid to
		objAdapter = New SqlDataAdapter(objCommand)
		objDataSet = New DataSet()
		objAdapter.Fill(objDataSet)
		' DataBind DG to DS
		dgPaging.DataSource = objDataSet
        dgPaging.DataBind()
		objConnection.Close()
	End Sub
	Sub PageChange(sender As Object, e As DataGridPageChangedEventArgs)
		dgPaging.CurrentPageIndex = e.NewPageIndex
		ShowDataGrid()
	End Sub
</script>
<html>
<head>
  <title>ASP.NET Database Paging Sample</title>
</head>
<body>
<form runat="server">
<!-- Plain vanilla DataGrid... format it as you like. -->
<asp:DataGrid id="dgPaging" runat="server"
  AllowPaging = "True"
  PageSize    = 10
  OnPageIndexChanged = "PageChange">
	<PagerStyle Mode="NumericPages" />
</asp:DataGrid>
</form>
<hr />
<p>
Click <a href="http://www.asp101.com/samples/db_paging_aspx.asp">here</a>
to read about and download the source code.
</p>
</body>
</html>