• AspNetPager 在ASP.NET 中的用法


    1.aspx

     <webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="false" PageSize="5"
                        CssClass="paginator" CurrentPageButtonClass="cpb" LastPageText="尾页" FirstPageText="首页"
                        PrevPageText="上一页" NextPageText="下一页" NumericButtonCount="4" PagingButtonSpacing="1px"
                         LayoutType="Table" OnPageChanged="AspNetPager1_PageChanged" >
               </webdiyer:AspNetPager>


    2.aspx.cs

      /// <summary>
            /// 绑定数据到Rpt
            /// </summary>
            /// <param name="bindlist"></param>
            private void DisplayData(int pageIndex, int pageSize)
            {
                AspNetPager1.RecordCount = newlist.Count;
                if (newlist.Count >= 5)
                {
                    var Fylist = from a in newlist orderby a.Contactid select a;
                    var q = Fylist.Skip((pageIndex-1) * pageSize).Take(pageSize);
                    rptlist.DataSource = q;
                    rptlist.DataBind();
                }
                else
                {
                    rptlist.DataSource = newlist;
                    rptlist.DataBind();
                }
            }
            protected void AspNetPager1_PageChanged(object sender, System.EventArgs e)
            {
                DisplayData(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize);  
            }

     3.CSS 样式

      /*************分页控件BEGIN*****************/
            /*拍拍网风格
            .paginator
            {
                font: 11px Arial, Helvetica, sans-serif;
                padding: 10px 20px 10px 0;
                margin: 0px;
            }
            .paginator a
            {
                padding: 1px 6px;
                border: solid 1px #ddd;
                background: #fff;
                text-decoration: none;
                margin-right: 2px;
            }
            .paginator a:visited
            {
                padding: 1px 6px;
                border: solid 1px #ddd;
                background: #fff;
                text-decoration: none;
            }
            .paginator .cpb
            {
                padding: 1px 6px;
                font-weight: bold;
                font-size: 13px;
                border: none;
            }
            .paginator a:hover
            {
                color: #fff;
                background: #ffa501;
                border-color: #ffa501;
                text-decoration: none;
            }
            */
            /*淘宝风格*/
            .paginator
            {
                font: 12px Arial, Helvetica, sans-serif;
                padding: 9px 19px 9px 0;
                margin: 0px;
            }
            .paginator a
            {
                border: solid 1px #ccc;
                color: #0063dc;
                cursor: pointer;
                text-decoration: none;
            }
            .paginator a:visited
            {
                padding: 1px 6px;
                border: solid 1px #ddd;
                background: #fff;
                text-decoration: none;
            }
            .paginator .cpb
            {
                border: 1px solid #F50;
                font-weight: 700;
                color: #F50;
                background-color: #ffeee5;
            }
            .paginator a:hover
            {
                border: solid 1px #F50;
                color: #f60;
                text-decoration: none;
            }
            .paginator a, .paginator a:visited, .paginator .cpb, .paginator a:hover
            {
                float: left;
                height: 16px;
                line-height: 16px;
                min-width: 10px;
                _width: 10px;
                margin-right: 5px;
                text-align: center;
                white-space: nowrap;
                font-size: 12px;
                font-family: Arial,SimSun;
                padding: 0 3px;
            }
            /*************分页控件END*****************/
  • 相关阅读:
    Windows 10 字体替换
    Windows 任务栏增加秒显示
    CCProxy v8.0 代理服务器
    Git RPM软件包 && 源码包
    Google Chrome 浏览器最新版本 71.0.3578.98(正式版本) (64 位)
    Linux 查询公网出口IP
    Windows 10 Enterprise LTSC做Windows To Go蓝屏无法进入系统
    Nginx编译./configure翻译
    Windows 10 快捷键
    JDBC连接MySQL
  • 原文地址:https://www.cnblogs.com/liuyu7177/p/3037793.html
Copyright © 2020-2023  润新知