zoukankan      html  css  js  c++  java
  • AspNetPager分页使用指南

    制作网页,很多时候要用到对数据进行分页。AspNetPager是一个很好的真分页工具。在网上查了一些资料。正在对这款强大的分页工具进行研究。

    以下是找到得相关资料,记录于此。

    AspNetPager分页实例:http://aspnetpager.51aspx.com/default.aspx

    AspNetPager几点说明,应用实例

    一、AspNetPager支持两种方式分页:
    一种是PostBack方式分页,
    一种是通过Url来实现分页以及Url重写功能
    二、AspNetPager支持各种数据绑定控件GridView、DataGrid、DataList、Repeater以及自定义的数据绑定控件的分页功能十分强大。
    三、AspNetPager分页控件本身并不显示任何数据,而只显示分页导航元素,数据在页面上的显示方式与该控件无关,所以需要手写数据连接方法来配合,
    四、结合TOP 。。。NOT IN 的通用存储过程分页方法使用AspNetPager十分实用

    测试控件datalist aspnetpager 的分页方法示例   分页方法为 PostBack 方式
    1、 首先将AspNetPager.dll复制于应用程序下的bin目录,打开解决方案,引入dll文件
    2、 在工具栏中添加控件,这样可以支持拖拽使用
    3、  要使用AspNetPager 要为其设置最基本的属性
    使用 SqlServer Northwind数据库的 Products表
    protected Wuqi.Webdiyer.AspNetPager AspNetPager1;
    protected System.Web.UI.WebControls.Label Label1;
    protected System.Web.UI.WebControls.DataList DataList1;
    private void Page_Load(object sender, System.EventArgs e)
    {
           this.AspNetPager1.PageSize=10;     //设置每页显示的记录条数
           if(!IsPostBack)                       //只在页面第一次加载时起作用
           {
                  SqlDBManager db = new SqlDBManager(System.Configuration.ConfigurationSettings.AppSettings["SqlConnectionString"]);
                  AspNetPager1.RecordCount=db.CountPage("products");//获得要使用表的记录总数
                                                                                                 //db.CountItems自定义的方法
                  this.BindData();                                  
           }
    }
    private void BindData()
    {
           SqlDBManager db= new SqlDBManager(System.Configuration.ConfigurationSettings.AppSettings["SqlConnectionString"].ToString();
           DataList1.DataSource=db.FenPage(this.AspNetPager1.PageSize,this.AspNetPager1.CurrentPageIndex,"productid","products","productid,productname,unitprice,unitsinstock","");
    //自定义方法由 TOP not in 存储过程分页方法改编
           this.DataList1.DataBind();                //控件数据绑定
           this.Label1.Text="当前第"+this.AspNetPager1.CurrentPageIndex+"页 总"+this.AspNetPager1.PageCount+"页";
    }
    private void AspNetPager1_PageChanged(object sender, System.EventArgs e)
    {       //页索引改变方法
        this.BindData();
    }

    设计页效果

          
                 

    产品ID 产品名称 产品数量 产品单价


          
                  <%# DataBinder.Eval(Container.DataItem,"Productid")%> <%# DataBinder.Eval(Container.DataItem,"productname")%> <%# DataBinder.Eval(Container.DataItem,"unitprice")%> <%# DataBinder.Eval(Container.DataItem,"unitsinstock")%>
          



     

    转载请注明出处:http://www.cnblogs.com/yssoft/archive/2009/05/03/1448251.html

  • 相关阅读:
    poj 1860 Currency Exchange(最短路径的应用)
    poj 2965 The Pilots Brothers' refrigerator
    zoj 1827 the game of 31 (有限制的博弈论)
    poj 3295 Tautology (构造法)
    poj 1753 Flip Game(枚举)
    poj 2109 (贪心)
    poj 1328(贪心)
    Qt 对单个控件美化
    Qt 4基础
    Bash Shell
  • 原文地址:https://www.cnblogs.com/CharmingDang/p/9664001.html
Copyright © 2011-2022 走看看