<%@Import Namespace="system.data"%>
<%@Import Namespace="system.data.sqlclient"%>
<html>
<asp:datagrid id="dg" allowpaging="true" pagesize="10" autogeneratecolumns="true" onpageindexchanged="pagechanged"/>
</html>
<script language="vb" runat="server">
Sub page_load(sender as object,e as eventargs)
dim strconn as string="server=svr;database=northwind;uid=sa;password=;"
dim conn as new sqlconnection(strconn)
dim strsql as string="select * from customers"
dim cmd as new sqlcommand(strsql,conn)
dg.datasource=cmd.executereader()
dg.databind()
End sub

Sub changepage(sender as object,e as datagridpagechangedeventargs)
dg.currentpageindex=e.newpageindex
dim strconn as string="server=svr;database=northwind;uid=sa;password=;"
dim conn as new sqlconnection(strconn)
dim strsql as string="select * from customers"
dim cmd as new sqlcommand(strsql,conn)
dg.datasource=cmd.executereader()
dg.databind()
End sub
</script>