zoukankan      html  css  js  c++  java
  • 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();
    }

  • 相关阅读:
    050819no JLINK device found
    050819流水账
    C语言附录的一些小摘要
    020819存疑点&error&warning
    020819流水账
    010819流水账
    310719存疑点&error&warning
    310719流水账
    300719流水账
    linux内核获取当前进程路径分析
  • 原文地址:https://www.cnblogs.com/chenbg2001/p/1709474.html
Copyright © 2011-2022 走看看