zoukankan      html  css  js  c++  java
  • AspNetPager.dll 分页控件使用

    今天在用.net 做网站的时候,用到了DATALIST,但是datalist 没有自带的分页控件,后来在网上找了好长时间,看了aspnetpager.dll这个控件,这个控件挺好用的.我把使用方法写出来,大家可以参考一下。

    先网上下载一个分页的控件。AspNetPager.dll 这个文件。

    先引用进来,添加引用那里添加进来。你也可以到工具箱那里,添加引用一下,工具箱上会多一个分页的控件的,到时候只要拖进到页面上就行了。

    <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

    这个放到页面头部

    <webdiyer:AspNetPager ID="AspNetPager1" runat="server" Width="100%" NumericButtonCount="6" UrlPaging="true" NumericButtonTextFormatString="[{0}]" CustomInfoHTML="第 <font color='red'><b>%CurrentPageIndex%</b></font> 页 共 %PageCount% 页 显示 %StartRecordIndex%-%EndRecordIndex% 条" ShowCustomInfoSection="left"
    FirstPageText="首页" LastPageText="末页" NextPageText="下页" PrevPageText="上页" Font-Names="Arial" BackColor="#EDEDED" AlwaysShow="true"   SubmitButtonText="跳转" SubmitButtonStyle="botton" OnPageChanging="AspNetPager1_PageChanging1" HorizontalAlign="Right" >
                  </webdiyer:AspNetPager>

    这个是一个写好的分页控件。样式都写好了~!

    bind() 这个 方法可以写到页面加载的地方load里面

    if(!ispostback)

    {

    bind();

    }

    -------------------------------------------------------------------------

     private void bind()
        {

            DataSet ds = new DataSet();
            string sql = "select b.* from  users";
            ds = conn.GetReader(sql);///用来统计总数用。。。。。conn.GetReader()是自己写的一个方法返回dataset
            this.AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;/////需要把记录的总数统计出来赋值给控件
            int pageIndex = this.AspNetPager1.CurrentPageIndex - 1;//定义要显示的页面
            int pageSize = this.AspNetPager1.PageSize = 6;///定义每页显示6条信息
     
            DataSet dd = new DataSet();
            dd = GVBind(sql, pageIndex, pageSize);

            this.dlp.DataSource = dd;
            dlp.DataBind();

        }

     protected void AspNetPager1_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
           AspNetPager1.CurrentPageIndex = e.NewPageIndex;
            bind();
        }

     public static DataSet GVBind(string strCom, int i1, int i2)
        {
            int firstPage = i1 * i2;

            SetConnection();/////调用数据链接的,我就不写出来
            DataSet ds = new DataSet();
            OleDbDataAdapter myDbAdp = new OleDbDataAdapter(strCom, myDbCon);


            myDbAdp.Fill(ds, firstPage, i2, "article");
            return ds;
        }

  • 相关阅读:
    rider中的gitbash如何从上次退出的目录启动
    docker swarm外部验证负载均衡时不生效
    css做一个可以变成关闭图标的菜单按钮
    mac外接键盘HOME,END键问题
    kubernetes实践录 使用Baget部署一个私有Nuget仓库
    C#中正确的实现IDisposable接口以释放非托管资源
    网络磁盘nfs使用笔记
    EFCore分组查询(GroupBy)后获取第一个元素
    Angular踩坑ExpressionChangedAfterItHasBeenCheckedError异常
    写了个适用于vscode的minio图床客户端插件 vscodeminiopicman
  • 原文地址:https://www.cnblogs.com/wqsbk/p/3570759.html
Copyright © 2011-2022 走看看