Studio for ASP.NET Wijmo:使用 C1Pager 对 DataList 控件分页

Studio for ASP.NET Wijmo 控件值得称赞的一点是它不仅仅单独为 C1 控件而开发。还可以配合其他控件使用,也正体现了C1控件为提高开发人员工作效率而设计的宗旨。简单的举一个例子,例如 C1Pager 就可以和 DataList 配合使用实现分页功能。

先上效果图:

Pager 

实现方法:

首先,我们需要设置 DataList 的数据源,在这个例子中我们使用OleDb 数据源创建DataSet。实现这个功能比较重要的一点是一旦生成数据源,我们需要把它同时赋值给C1Pager PagedDataSource  类。需要为每个页面设置页码。以下为实现代码:

 
 
  1: OleDbDataAdapter dadapter;
  2: DataSet dset;
  3: PagedDataSource adsource;
  4: string connstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("~/App_Data/NWIND.mdb") + ";Persist Security Info=False";
  5: int pos;
  6: int pageCount = 0;
  7:   
  8: protected void Page_Load(object sender, EventArgs e)
  9: {
 10:    if (!IsPostBack)
 11:    {
 12:       this.ViewState["vs"] = 0;
 13:    }
 14:    pos = (int)this.ViewState["vs"];
 15:    DataBind();
 16:    C1Pager1.PageCount = pageCount;
 17:    C1Pager1.Mode = C1.Web.Wijmo.Controls.C1Pager.PagerMode.Numeric;
 18: }

 

以下是 DataBind 方法的实现代码:

 
 
  1: public void DataBind()
  2: {
  3:    dadapter = new OleDbDataAdapter("SELECT TOP 20 CompanyName, City, Country FROM Customers", connstring);
  4:    dset = new DataSet();
  5:    adsource = new PagedDataSource();
  6:    dadapter.Fill(dset);
  7:    adsource.DataSource = dset.Tables[0].DefaultView;
  8:    adsource.PageSize = 5;
  9:    adsource.AllowPaging = true;
 10:    adsource.CurrentPageIndex = pos;
 11:    DataList1.DataSource = adsource;
 12:    DataList1.DataBind();
 13:    pageCount = Convert.ToInt32(dset.Tables[0].Rows.Count / adsource.PageSize);
 14: }

 

接下来需要通过 C1Pager 的点击实现为 DataList 切换数据,实现分页效果:

 
 
  1: protected void C1Pager1_PageIndexChanged(object sender, EventArgs e)
  2: {
  3:    int currPage = C1Pager1.PageIndex;
  4:    pos = (int)this.ViewState["vs"];
  5:    pos += currPage;
  6:    this.ViewState["vs"] = pos;
  7:    DataBind();
  8:    pos = 0;
  9:    this.ViewState["vs"] = 0;
 10: }

 

好了,通过以上步骤我们就结合 C1Pager 和 DataList 实现了完美的真分页。每次点击C1Pager页码时都会回调后台的DataBind方法来刷新DataList的数据。以下是示例,赶快下载体验吧:

VS2010+Framework 4.0 + C# 点击下载

VS2010+Framework 4.0 + VB.NET 点击下载

下载 Stduio for ASP.NET Wijmo 产品请进入:

http://www.gcpowertools.com.cn/products/componentone_studio_asp.htm

转载于:https://www.cnblogs.com/C1SupportTeam/p/studioforaspnet_c1pager.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ComponentOne Studio for ASP.NET Wijmo 2013 v1 2/5 共五个压缩文件,请全部下载后解压 Part of: Ultimate | Enterprise 40+ styled, supercharged, and easy-to-use controls built on Web standards including AJAX, CSS, HTML5, and jQuery. One Technology for All ASP.NET Development One Technology for All ASP.NET Development Take on any project with a single technology that provides everything from pure client-side development to robust server-side development. Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn more about the ComponentOne Web Stack. The Most Innovative Technology The Most Innovative Technology Your web applications will perform faster, run smoother, and be more engaging than even before. Built with HTML5, jQuery, CSS3, and SVG, Studio for ASP.NET Wijmo controls make your applications suitable for Today's Web. Effortless Application-wide Theming Effortless Application-wide Theming Easily develop a consistent look and feel across your entire application. Start by using the six professionally designed themes pre-packaged in ComponentOne’s ASP.NET Wijmo controls. Optionally, choose from over 30 themes from the jQuery UI project or use ThemeRoller from jQuery UI to create your own custom theme. Learn more about the Studio for ASP.NET Wijmo rich theming architecture or launch the ASP.NET Theme Explorer to see for yourself. Full Cross-browser Compatibility Full Cross-browser Compatibility Ensure your UI works in every browser and every device without worrying about compatibility issues. Create interactive charts that render just as well in IE6 as they do on an iPad. Studio for ASP.NET Wijmo controls support these popular browsers: IE6+, Firefox 3+, Safari 3+, and Chrome. Unmatched Performance In modern Web development, client-side download and performance are critical. With those key factors in mind, we created a new high-performance client-side framework (Wijmo). Using Studio for ASP.NET Wijmo controls you can choose whether features are executed on the client or server. Easily develop responsive applications that minimize Postbacks to the server, and experience unmatched performance with quick client-side download and scripting optimization on the client. Built-in Web Standards and Accessibility Built-in Web Standards and Accessibility Web Standards like semantic markup, progressive enhancement, and CSS styling are important elements of robust web development. Just the same, accessibility enhancements like Section 508 compliance and ARIA support are vital. Be certain your controls use Web Standards and meet strict accessibility guidelines with Studio for ASP.NET Wijmo. Premium Support Premium Support You don't have to worry about questions slowing you down. Get fast and professional help while using our tools with Premium support. From our 24-hour support response guarantee to our knowledge-rich online community, enjoy unmatched support. Complete Documentation Get started quickly by referencing in-depth documentation and samples with full source code. Searching for something specific? Take a look at the Studio for ASP.NET Wijmo documentation, which includes quick starts, tutorials, syntax, and more. Or, explore the controls by playing with the Studio for ASP.NET Wijmo demos.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值