【Asp.Net WebFrom】分页
2014-08-06 18:59
369 查看
Asp.Net WebForm 分页
一、 前言
Asp.Net WebForm 内置的DataPager让人十分蛋疼
本文使用的分页控件是第三方分页控件 AspNetPager,下载地址:
链接: http://pan.baidu.com/s/1eQJ2HR8 密码: aost
相关属性及其效果图:
View Code
一、 前言
Asp.Net WebForm 内置的DataPager让人十分蛋疼
本文使用的分页控件是第三方分页控件 AspNetPager,下载地址:
链接: http://pan.baidu.com/s/1eQJ2HR8 密码: aost
相关属性及其效果图:
using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Focus.Asp.WebForm.Czbk.Focus.Helper; using Focus.Asp.WebForm.Czbk.Focus.ValidateControl; namespace Focus.Asp.WebForm.Czbk.Focus.ListView { public partial class ListView分页AspNetPager第三方控件 : System.Web.UI.Page { private int pageIndex; private int pageSize = Convert.ToInt32(ConfigurationManager.AppSettings["pageSize"]); private int totalCount; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); } } protected void AspNetPager1_OnPageChanged(object sender, EventArgs e) { BindData(); /*设置分页控件属性*/ this.AspNetPager1.CustomInfoHTML = "记录总数:<b>" + AspNetPager1.RecordCount.ToString() + "</b>"; this.AspNetPager1.CustomInfoHTML += " 总页数:<b>" + AspNetPager1.PageCount.ToString() + "</b>"; this.AspNetPager1.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>"; } private void BindData() { List<Electronics> dataSource = DataSourceTemplete.GetElectronics(); pageIndex = this.AspNetPager1.CurrentPageIndex; totalCount = DataSourceTemplete.GetElectronics().Count; this.ListView1.DataSource = dataSource.Skip(pageIndex-1 * pageSize) .Take(pageSize) .ToList(); ; this.ListView1.DataBind(); /*设置分页控件属性*/ this.AspNetPager1.RecordCount = totalCount;//所有数据的总数,必须设置该值。 this.AspNetPager1.PageSize = pageSize; } } }
View Code
相关文章推荐
- consume an asp.net webservice(upload a file to server) from java via soap
- Beginning Web Development, Silverlight, and ASP.NET AJAX: From Novice to Professional
- php 模拟 asp.net webFrom 按钮提交事件
- ASP.NET WebFrom机制中前台显示后台数据的几个易混点
- WebPager For ASP.NET (基于ASP.NET的数据分页控件)
- Using The Amazon Web Service From ASP.NET
- Asp.Net其他页面如何调用Web用户控件写的分页
- How to Migrate from WCF Web API to ASP.NET Web API
- ASP.NET MVC Web API Post FromBody(Web API 如何正确 Post)
- Asp.Net Web控件 (六)(分页控件)
- Asp.Net Web控件 (四)(可分页的Repeater)
- Contention, poor performance, and deadlocks when you make Web service requests from ASP.NET applications
- 转:Manage Web.config from XML File by using configSource attribute ASP.Net 2.0
- Web Parts: From SharePoint to ASP.NET 2.0
- Read ConnectionString from web.config in ASP.NET 2.0
- Embed client-side JavaScript in an ASP.NET 1.1 web page from server side code
- ASP.NET MVC与Web From的使用时机?
- ASP.NET MVC Web API Post FromBody(Web API 如何正确 Post)