zoukankan      html  css  js  c++  java
  • ASP.NET 分页数据源:: PagedDataSource //可分页数据源

    Demo


            
    int pagetCount = Convert.ToInt32(this.Label1.Text);
             SqlConnection con
    = DB.con;
             SqlDataAdapter sda
    = new SqlDataAdapter();
             DataSet ds
    = new DataSet();
             PagedDataSource ps
    = new PagedDataSource();//可分页数据源
             sda.SelectCommand = new SqlCommand("select top(90) * from books", con);
            
    try
             {
                 con.Open();
                 sda.Fill(ds,
    "books");
                 ps.DataSource
    = ds.Tables["books"].DefaultView;//初始化可分页数据源的数据源属性
                 ps.AllowPaging = true;//设置为可分页
                 ps.PageSize = 10;//设置每页显示多少行数据
                 ps.CurrentPageIndex = pagetCount - 1;//设置当前页
                this.Button1.Enabled = true;
                
    this.Button2.Enabled = true;

                
    this.Repeater1.DataSource = ps;//用可分页数据源初始Repeater控件
                this.Repeater1.DataBind(); //绑定   
                if (pagetCount==1)
                 {
                    
    this.Button1.Enabled = false;
                 }
                
    if (pagetCount == ps.PageCount)
                 {
                    
    this.Button2.Enabled = false;
                 }
    作者:BuildNewApp
    出处:http://syxchina.cnblogs.comBuildNewApp.com
    本文版权归作者、博客园和百度空间共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则作者会诅咒你的。
    如果您阅读了我的文章并觉得有价值请点击此处,谢谢您的肯定1。
  • 相关阅读:
    机器学习个人总结
    yolo buffer is too small for requested array
    anaconda + VSCode + 生产环境配置
    YOLO.h5 下载
    通过爬虫程序深入浅出java 主从工作模型
    KafKa记录
    springboot 整合spark-sql报错
    机器学习项目笔记
    python学习笔记之入门
    django-5-使用数据库
  • 原文地址:https://www.cnblogs.com/syxchina/p/2197355.html
Copyright © 2011-2022 走看看