AspNetPager sql 分页 Repeater(附分页控件DLL下载)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sousuo.aspx.cs" Inherits="sousuo" %>



<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>


要加这段  不然 会找不到控件



上次MYSQL的时候也将到了,利用AspNetPager 来进行分页,但是这次是用SQL来做,有时候 自己也会有点懵,不就是换下SQL连接的查询代码吗?


AspNetPager_sql_分页_Repeater(附分页控件DLL下载)






前台代码


       
       

      <%#Eval("名称")%> 

      <%#Eval("点击量")%> 

        
   


加上下面这段



    
             PageSize="20" CssClass="paginator"  CurrentPageButtonClass="cpb"
    LastPageText="尾页" FirstPageText="首页" PrevPageText="上一页" NextPageText="下一页"
     UrlPaging="false" NumericButtonTextFormatString="{0}"
     ShowCustomInfoSection="Left"  CustomInfoTextAlign="Left" LayoutType="Table" 
            
            CustomInfoHTML="页数 %CurrentPageIndex% of %PageCount%" ShowBoxThreshold="11" 
            UrlPageIndexName="页数" >

   




下面这里是淘宝风格 也加在下面即可







后台绑定代码:


        string conn = "server=.;database=数据库;uid=sa;pwd=****"; ;

        SqlConnection con = new SqlConnection(conn);
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from list order by Convert(int,点击量) desc", con);
        SqlDataReader dr = cmd.ExecuteReader();
        SqlDataAdapter adr = new SqlDataAdapter("select * from list order by Convert(int,点击量) desc ", conn);
        DataSet T = new DataSet();
        adr.Fill(T, "点击量");




        PagedDataSource pdsList = new PagedDataSource();
        pdsList.DataSource = T.Tables[0].DefaultView;
        pdsList.AllowPaging = true;//数据源允许分页
        pdsList.PageSize = this.AspNetPager1.PageSize;//取控件的分页大小
        pdsList.CurrentPageIndex = this.AspNetPager1.CurrentPageIndex - 1;//显示当前页
        //设置控件
        this.AspNetPager1.RecordCount = T.Tables[0].Rows.Count;//记录总数
        this.AspNetPager1.PageSize = 50;
        this.Repeater1.DataSource = pdsList;
        this.Repeater1.DataBind();










webform
标签:AspNetPager sql 分页 Repeater