绑定Repeater实现分页获取数据
来源:互联网 发布:网络歌手灰色天空 编辑:程序博客网 时间:2024/05/17 18:45
<pre name="code" class="csharp">public partial class _Default : System.Web.UI.Page { int currentpage = 0; int indexSize = 2; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List<string> values = new List<string>(); values.Add("Apple"); values.Add("Orange"); values.Add("Pear"); values.Add("Banana"); values.Add("Grape"); rpt.DataSource = values; rpt.DataBind(); Session.Add("pageSize", indexSize); Session.Add("source", values); } } private List<string> get(int index) { List<string> data = (List<string>)Session["source"]; List<string> result = new List<string>(); int pageSize= (int)Session["pageSize"]; int bigIndex = (int)System.Math.Ceiling(Convert.ToDecimal(data.Count) / indexSize); if (bigIndex<index) { return new List<string>(); } int first = index == 1 ? 0 : (index - 1) * indexSize; int end = bigIndex == index ? data.Count : index* pageSize; for (int i = first; i < end; i++) { result.Add(data[i]); } return result; } protected void pageindex_TextChanged(object sender, EventArgs e) { bool success = Int32.TryParse(pageindex.Text, out currentpage ); if (success) { List<string> result = get(currentpage); rpt.DataSource = result; rpt.DataBind(); } }}
0 0
- 绑定Repeater实现分页获取数据
- Repeater控件实现数据绑定,并实现分页效果
- ASP.NET Repeater绑定数据并实现分页
- ASP.NET Repeater绑定数据并实现分页
- ASP.NET Repeater绑定数据并实现分页
- Repeater控件绑定数据、分页、数据操作,最佳代码
- 使用Repeater控件实现数据绑定
- 利用Repeater控件实现数据分页显示
- jquery 实现分页绑定复选框选中状态(Repeater控件)
- repeater与数据绑定
- Repeater嵌套绑定数据
- repeater数据绑定
- repeater绑定数据
- Repeater嵌套绑定数据
- repeater控件绑定数据
- 嵌套repeater数据绑定
- Repeater动态绑定数据
- Repeater多层绑定数据
- 1015. 德才论 (25)
- ubuntu15.10下wine问题
- 谈一点我对hibernate关联关系映射的看法
- 一个字体的设计
- 1016. 部分A+B (15)
- 绑定Repeater实现分页获取数据
- git的基本使用
- linux下C语言基础学习笔记2
- return和exit
- 高中同学聚会有感
- ios开发——UITextView展示txt电子书时的页数调整
- lightoj1149 - Factors and Multiples【二分图最大匹配】
- x86 系列 CPU 内存寻址模式总结
- 位置无关(PIC)代码原理剖析