zoukankan      html  css  js  c++  java
  • 使用AspNetPager分页的范例

    很多人看了AspNetPager提供的例子,因为写得比较多其他的属性,所以在这里提供最简单的范例
     private void Page_Load(object sender, System.EventArgs e)
      {
       // 在此处放置用户代码以初始化页面
       //求该数据集合的记录总和
       if(!Page.IsPostBack)
       {
        SqlDataBase SqlDB=new SqlDataBase(DSN);
        string strsql="Select count(user_id) from IU_User";
        DataSet ds= SqlDB.CreateSet(strsql,"IUser");
        this.AspNetPager1.RecordCount=System.Convert.ToInt32(ds.Tables[0].Rows[0][0]) ;
        SqlDB.CloseConnection();
        BindData();
       }
      }
    void BindData()
      {
       SqlDataBase SqlDB=new SqlDataBase(DSN);
       string strsql="Select User_ID, UserName, PassWord  from IU_User";
       SqlDataAdapter adapter= SqlDB.CreateAdapter(strsql);
        DataSet ds=new DataSet();
                adapter.Fill(ds,AspNetPager1.PageSize*(AspNetPager1.CurrentPageIndex-1),AspNetPager1.PageSize,"IU_User");  
       this.DataGrid1.DataSource=ds.Tables["IU_User"];
       this.DataGrid1.DataBind();
          //动态设置用户自定义文本内容
       AspNetPager1.CustomInfoText="记录总数:<font color=\"blue\"><b>"+AspNetPager1.RecordCount.ToString()+"</b></font>";
       AspNetPager1.CustomInfoText+=" 总页数:<font color=\"blue\"><b>"+AspNetPager1.PageCount.ToString()+"</b></font>";
       AspNetPager1.CustomInfoText+=" 当前页:<font color=\"red\"><b>"+AspNetPager1.CurrentPageIndex.ToString()+"</b></font>";

      }

      private void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
      {
       AspNetPager1.CurrentPageIndex=e.NewPageIndex;
       BindData();
       System.Text.StringBuilder sb=new StringBuilder("<script Language=\"Javascript\"><!--\n");
       sb.Append("var el=document.all;");
       sb.Append(this.DataGrid1.ClientID);
       sb.Append(".scrollIntoView(true);");
       sb.Append("<");
       sb.Append("/");
       sb.Append("script>");
       if(!Page.IsStartupScriptRegistered("scrollScript"))
        Page.RegisterStartupScript("scrollScript",sb.ToString());
      }

  • 相关阅读:
    python接口自动化(三)--如何设计接口测试用例(详解)
    python接口自动化(二)--什么是接口测试、为什么要做接口测试(详解)
    python接口自动化(一)--什么是接口、接口优势、类型(详解)
    PostgreSQL建立分区表示例
    PostgreSQL中的时间操作总结
    linux系统命令:yum和apt-get
    oracle中的连接查询与合并查询总结
    oracle中时间运算
    oracle中一些用法总结
    oracle中substr与instr
  • 原文地址:https://www.cnblogs.com/meetweb/p/107481.html
Copyright © 2011-2022 走看看