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。
原文地址:https://www.cnblogs.com/syxchina/p/2197355.html