用datagrid控件显示数据时,每一页我设置可显示5条记录。数据库中有20条记录,原本可用五页来显示的。页码数是1,2,3,4,5。但页码数只显示1.请问是怎么回事。代码如下:前台:
<body MS_POSITIONING="GridLayout"><form id="Form1" method="post" runat="server"><asp:DataGrid id="DataGrid1" PageSize="5" AllowPaging="True" AllowCustomPaging="True" HorizontalAlign="Center"OnPageIndexChanged="datagrid_changed" runat="server" Width="576px"><ItemStyle Font-Size="11pt" ForeColor="Black" BackColor="Moccasin"></ItemStyle><HeaderStyle Font-Size="11pt" HorizontalAlign="Center" ForeColor="#FFFFCC" BackColor="#66CCFF"></HeaderStyle><PagerStyle Font-Size="13pt" Font-Names="corier" HorizontalAlign="Center" ForeColor="Blue" BackColor="#FFFFCC"PageButtonCount="15" Mode="NumericPages"></PagerStyle></asp:DataGrid></FONT></form></body>-----------------------------------------------后台:Imports System.DataImports System.Data.OleDb...Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then databindgrid() End Sub Sub databindgrid() Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("page.mdb")) Dim apt As New OleDbDataAdapter("select topic as 主题,content as 内容 from data", conn) Dim ds As New DataSet apt.Fill(ds, "data") DataGrid1.DataSource = ds DataGrid1.DataBind() End Sub Sub datagrid_changed(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs) DataGrid1.CurrentPageIndex = e.NewPageIndex databindgrid()
End Sub
[此贴子已经被作者于2006-3-10 0:59:08编辑过]