<%@ Import namespace="System.data"%>
<%@ Import namespace="system.data.OleDb"%>
<script language="VB" runat="server">
sub page_Lode(sender as object,E as eventargs)
IF Not Page.IsPostBack then
call BindData '绑定数据
end if
end sub
'单击导航栏的页码时执行该过程
sub MyDataGrid_page(sender as object,e as DataGridPageChangedEventArgs)
MyDataGrid.CurrentPageIndex=e.NewPageIndex '设置要显示的新页
call BindData() '绑定数据
end sub
sub BindData()
dim conn as New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data source="&server.Mappath("wwwlink.mdb")) '建立connection对象
dim adp as new OleDbDataAdapter("select*from link",conn) '建立DataAdapter对象
dim ds as new DataSet() '建立dataset对象
adp.Fill(ds,"link") '填充Dataset对象
MyDataGrid.DataSource=DS.Tables("link").defaultView '指定数据源
MyDataGrid.DataBind() '执行绑定
end sub
</script>
<html>
<body>
<h4 align="center">网络导航</h4>
<form runat="server">
<ASP:DataGrid id="MyDataGrid" HeaderStyle-BackColor="#BCBCBC" width="100%"
AllowPaging="True" PageSize="5" OnPageIndexChanged="MyDataGrid_Page"
PagerStyle-HorizontalAlign="Right" PagerStyle-Mode="numericPages" runat="server"/>
</form>
</body>
</html>
程序运行结果图为: