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

  • 相关阅读:
    制作透明色:《CSS3 RGBA》与Opacity样式用法
    制作动画效果:《CSS3 Animation》
    CISCO运维记录之3650堆叠设备升级IOS(Version 16.3.6版本存在bug)
    08 Zabbix4.0系统配置事件通知
    24 Zabbix系统配置日志监控告警--关键字触发
    15 Zabbix Item类型之Zabbix trapper类型
    06 Zabbix4.0系统CISCO交换机告警模板规划信息(基础)
    05 Zabbix4.0触发器表达式Trigger expression支持的函数
    04 Zabbix4.0系统配置触发器trigger
    03 Zabbix4.0添加cisco交换机基本监控步骤
  • 原文地址:https://www.cnblogs.com/meetweb/p/107481.html
Copyright © 2011-2022 走看看