陈宝刚---享受生活,追逐梦想!
理想是心中的火焰,有追求的人才是幸福的人!

DataSet ds;
SqlDataAdapter dr;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection("server=.;uid=sa;database=数据库");
con.Open();
com = new SqlCommand();
com.Connection = con;
com.CommandText = "select count(*) from Employees";
AspNetPager1.AlwaysShow=true;
AspNetPager1.PageSize=15;
AspNetPager1.RecordCount = (int)com.ExecuteScalar();
con.Close();
DataListDataBind();
}
}
private void DataListDataBind()
{
SqlConnection con = new SqlConnection("server=.;uid=sa;database=数据库");
dr = new SqlDataAdapter("select * from Employees", con);
ds = new DataSet();
dr.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "Employees");
DataList1.DataSource = ds.Tables["Employees"];
DataList1.DataBind();

}

protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
DataListDataBind();
}

posted on 2010-04-11 12:45  追梦人RUBY  阅读(221)  评论(0编辑  收藏  举报