欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

aspnetpager的使用(完美篇)

发布时间:2024/1/17 52 豆豆
生活随笔 收集整理的这篇文章主要介绍了 aspnetpager的使用(完美篇) 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

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();
}

转载于:https://www.cnblogs.com/chenbg2001/archive/2010/04/11/1709474.html

总结

以上是生活随笔为你收集整理的aspnetpager的使用(完美篇)的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。