打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Repeater 控件 + 分页控件的使用

前台页面 A.aspx:

 

 

 

=============================

后台代码 A.aspx.cs:

 

public partial class ConventionList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindToDataList();
        }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindToDataList();
    }
 
    private void BindToDataList()
    {
        int pageIndex = this.AspNetPager1.CurrentPageIndex - 1;
        int pageSize = 5;
        this.AspNetPager1.PageSize = pageSize;
        int firstPage = pageIndex * pageSize;
 
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
 
        string sql = "select M.ExhibitionID,M.SystemID,M.TitleValue,M.ContentValue,M.ScopeValue,M.OrganizerValue,Country.CountryName,Area.AreaName,E.ExhibitionID,E.HttpUrl,E.StartDT,E.EndDT,E.ImageUrl from Country left join Area on Country.CountryID=Area.CountryID left join Pavilion on Area.AreaID=Pavilion.AreaID left join Exhibition E on E.PavilionID=Pavilion.PavilionID left join MultiLangExpo M on M.ExhibitionID=E.ExhibitionID where M.SystemID=1 and E.TypeID=1 and E.deleted=0 and StartDT > getDate() order by StartDT Desc";
        SqlDataAdapter da = new SqlDataAdapter(sql,conn);
        DataSet ds = new DataSet();
        da.Fill(ds, firstPage, pageSize, "listall");
        DataTable dt = ds.Tables["listall"];
        AspNetPager1.RecordCount = getCount(); 
        rptList.DataSource = dt;
        rptList.DataBind();
    }
    private int getCount()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
        string sql = "";
        sql = "select Count(E.ExhibitionID) from Country left join Area on Country.CountryID=Area.CountryID left join Pavilion on Area.AreaID=Pavilion.AreaID left join Exhibition E on E.PavilionID=Pavilion.PavilionID left join MultiLangExpo M on M.ExhibitionID=E.ExhibitionID where M.SystemID=1 and E.TypeID=1 and E.deleted=0 and StartDT > getDate()";
        SqlCommand com = new SqlCommand(sql, con);
        con.Open();
        int temp = Convert.ToInt32(com.ExecuteScalar());
        con.Close();
        return temp;
    }
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
简单的ASP.NET无刷新分页
AspNetPager分页控件
ASP.NET 2.0 中AspNetPager.dll控件的分页方法操作方法
ASPNETPAGER分页控件的使用方法[图文]
Asp.Net数据控件引用AspNetPager.dll分页实现代码
分页
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服