protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OleDbCommand cmd;
OleDbConnection conn;
string strcnn, sql;
strcnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("EDNdata/EDNdatabase.mdb");
sql = "select count(id) from Info where ZClass=1";
conn = new OleDbConnection(strcnn);
conn.Open();
cmd = new OleDbCommand(sql, conn);
AspNetPager1.RecordCount = (int)cmd.ExecuteScalar();
conn.Close();
Info_A_Bind();
}
}
//-----------------------------------------------------------------------
public void Info_A_Bind()
{
OleDbConnection cnn;
OleDbDataAdapter cmd;
DataSet dt=new DataSet();
DataSet ds = new DataSet();
string strcnn,sql;
strcnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("EDNdata/EDNdatabase.mdb");
cnn=new OleDbConnection(strcnn);
cnn.Open();
sql = "select id,ZClass,ZCName,SClass,SCName,Title,DataN from Info where ZClass=1 order by id desc";
cmd=new OleDbDataAdapter(sql,cnn);
cmd.Fill(dt,"Info");
int counts = dt.Tables["Info"].Rows.Count;
la3.Text = counts.ToString();
cmd.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "news");
repeater3.DataSource = ds;
repeater3.DataBind();
cnn.Close();
}
//----------------------------------------------------
void ChangePage(object src,EventArgs e)
{
Info_A_Bind();
}
//---------------------------------------------------
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
分页只看到第一页的数据..点击第二第三页的数据跟第一页的是一样的