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

  • 相关阅读:
    text-overflow white-space word-break word-wrap word-spacing line-clamp 傻傻分不清楚0.0=>文本超出显示省略号/数字英文字母折行有关css 属性/显示两行,第二行省略号显示css方法
    jq 操作表单中 checkbox 全选 单选
    用 pdf.js兼容部分安卓显示PDF在线预览 时,a标签直接链接参数文件不能含中文的解决办法
    通过form实现enter事件
    小白随笔之数组的方法
    引用类型之Array
    Reset
    js常用事件
    让女朋友能懂的网络技术篇之动态代理
    图论之Dijkstra算法
  • 原文地址:https://www.cnblogs.com/meetweb/p/107481.html
Copyright © 2011-2022 走看看