[CODE]<%@ Page Language="C#" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server">
void Page_Load(Object sender,EventArgs e) { int Total,Current,Size; Size = 5; if(!Page.IsPostBack) { Current = 1; } else { Current = 1; //Current = Convert.ToInt32(Request.QueryString["PageNumber"]); } OleDbCommand myCommand; OleDbConnection myConnection = new OleDbConnection(); string dbname; dbname = Server.MapPath("a.mdb"); myConnection.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+dbname; myConnection.Open(); OleDbDataAdapter dp = new OleDbDataAdapter("SELECT * FROM a",myConnection); DataSet ds = new DataSet(); //dp.Fill(ds,"table"); //Total = ds.Tables[0].Rows.Count; Total = 20; ds.Clear(); if(Current<=Total/Size&&Current>0) { dp.Fill(ds,(Current-1)*Size,Size,"table 1"); } else { dp.Fill(ds,0,Size,"table 1"); } MyDataGrid.DataSource = ds; MyDataGrid.DataBind(); Label1.Text = Convert.ToString(Current)+" "+Convert.ToString(Size); }
</script> <html> <head> </head> <body> <form runat="server"> <table width="70%" align="center" border="1"> <asp:Repeater id="MyDataGrid" runat="server"> <ItemTemplate> <tr> <td> <%# DataBinder.Eval(Container.DataItem,"col1")%> </td> <td> <%# DataBinder.Eval(Container.DataItem,"col2")%> </td> <td> <%# DataBinder.Eval(Container.DataItem,"col3") %> </td> </tr> </ItemTemplate> </asp:Repeater> <tr><td colspan="3"> <asp:Label ID = "Label1" runat = "server"/> </td></tr> </table> </form> </body> </html> [/CODE]这里是全部代码