您现在的位置是:网站首页> 编程资料编程资料
asp.net控件DataList分页用法_实用技巧_
2023-05-24
331人已围观
简介 asp.net控件DataList分页用法_实用技巧_
本文实例讲述了asp.net控件DataList分页用法。分享给大家供大家参考,具体如下:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["Page"] = 0; Bangding(); } } //绑定数据 public void Bangding() { PagedDataSource pds = new PagedDataSource(); pds.DataSource = MerchandiseManager.GetList(""); pds.AllowPaging = true; pds.PageSize = 5; //每页记录数 pds.CurrentPageIndex = Pager;//当前页 lblCurrPage.Text = "第" + (pds.CurrentPageIndex + 1).ToString() + "页 共" + pds.PageCount.ToString() + "页"; SetEnable(pds);//上下页按钮的有效壮态 dlistMerchand.DataSource = pds; dlistMerchand.DataBind(); } private int Pager { get { return (int)ViewState["Page"]; } set { ViewState["Page"] = value; } } //下一页 protected void LinkButton1_Click(object sender, EventArgs e) { Pager++; Bangding(); } //上一页 protected void LinkButton2_Click(object sender, EventArgs e) { Pager--; Bangding(); } //上下页按钮的有效壮态 private void SetEnable(PagedDataSource pds) { btnShang.Enabled = true; btnXia.Enabled = true; if (pds.IsFirstPage) { btnShang.Enabled = false; } if (pds.IsLastPage) { btnXia.Enabled = false; } } 更多关于asp.net相关内容感兴趣的读者可查看本站专题:《asp.net字符串操作技巧汇总》、《asp.net操作XML技巧总结》、《asp.net文件操作技巧汇总》、《asp.net ajax技巧总结专题》及《asp.net缓存操作技巧总结》。
希望本文所述对大家asp.net程序设计有所帮助。
您可能感兴趣的文章:
相关内容
- 在ASP.NET 2.0中操作数据之三十八:处理BLL和DAL的异常_自学过程_
- asp.net图片文件的上传与删除方法_实用技巧_
- 在ASP.NET 2.0中操作数据之三十七:DataList批量更新_自学过程_
- asp.net中调用存储过程的方法_实用技巧_
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程_自学过程_
- 在ASP.NET 2.0中操作数据之三十六:在DataList里编辑和删除数据概述_自学过程_
- ASP.NET三层架构详解 如何实现三层架构_实用技巧_
- 详解ASP.NET验证码的生成方法_实用技巧_
- WinForm中DataGridView折叠控件【超好看】_实用技巧_
- 详解ASP.NET中Session的用法_实用技巧_
