在下面界面代码中,还要加什么才可以实现分页?
<asp:DataGrid ID="mygird" runat="server" AllowPaging="true" AlternatingItemStyle-BackColor="Gold" Caption="sheet1" PageSize=5 SelectedItemStyle-BackColor="SlateGray" ></asp:DataGrid>
cs代码是下面的,这里还要加什么才能实现分页
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ts : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connstr = "provider=microsoft.jet.oledb.4.0;data source=" + Server.MapPath("data.mdb");
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = connstr;
try{
conn.Open();
Response.Write("成功打开数据库");
}
catch{
Response.Write("失败");
}
string sql = "select * from kehu";
OleDbDataAdapter myadapter=new OleDbDataAdapter(sql,conn);
DataSet mydataset=new DataSet();
myadapter.Fill(mydataset,"kehu");
mygird.DataSource=mydataset.Tables["kehu"].DefaultView;
mygird.DataBind();
}
}
各位帮帮忙.