• AspNetPage分页查询使用方法 分页风格


    一、绑定方法
    private void DataBindDataTable(string whereCondition) { //whereCondition是查询的条件
            IList<Sr_TakeNameListEntity> list = SrTakeNameListManage.GetSrTabkeNameAllList(whereCondition);
            AspNetPager1.RecordCount = list.Count;//设置总条数

            PagedDataSource pds = new PagedDataSource();
            pds.DataSource = list;
            pds.AllowPaging = true;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;//当前页的索引
            pds.PageSize = AspNetPager1.PageSize;//每页显示的记录数
            GridView1.DataSource = pds;
            GridView1.DataBind();
        }

    二、页面首次加载
           if(!IsPostBack){
               ViewState["vkey"]=" 1=1 ";//查询条件的关键字
               DataBindDataTable(ViewState["vkey"].ToString());
            }

    三、AspNetPage事件
       protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            DataBindDataTable(ViewState["vkey"].ToString());
        }

    四、搜索按钮单击事件
        protected void btnAllSearch_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            ViewState["vkey"] = " 1=1 ";
            DataBindDataTable(ViewState["vkey"].ToString());
        }

    ---ViewState 在执行查询后并不能保存前台文本框查询条件数据,我最终只能用session保存查询后的条件数据,不知道谁有没有更好的方法

       <h4>网易风格:</h4>
    <webdiyer:AspNetPager CssClass="anpager" CurrentPageButtonClass="cpb" ID="AspNetPager2" runat="server" RecordCount="228"
            FirstPageText="首页" LastPageText="尾页" NextPageText="后页" PrevPageText="前页">
        </webdiyer:AspNetPager>

    /*网易风格*/
    .anpager .cpb {background:#1F3A87 none repeat scroll 0 0;border:1px solid #CCCCCC;color:#FFFFFF;font-weight:bold;margin:5px 4px 0 0;padding:4px 5px 0;}
    .anpager a {background:#FFFFFF none repeat scroll 0 0;border:1px solid #CCCCCC;color:#1F3A87;margin:5px 4px 0 0;padding:4px 5px 0;text-decoration:none}
    .anpager a:hover{background:#1F3A87 none repeat scroll 0 0;border:1px solid #1F3A87;color:#FFFFFF;}

    <h4>拍拍网风格:</h4>
        <webdiyer:AspNetPager CssClass="paginator" CurrentPageButtonClass="cpb" ID="AspNetPager3" runat="server" RecordCount="228"
            FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页">

    /*拍拍网风格*/
    .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;}

    <h4>迅雷风格:</h4>
        <webdiyer:AspNetPager CssClass="pages" CurrentPageButtonClass="cpb" ID="AspNetPager4" runat="server" RecordCount="228"
            FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页">
        </webdiyer:AspNetPager>

    /*迅雷风格*/
    .pages { color: #999 }
    .pages a, .pages .cpb { text-decoration:none;float: left; padding: 0 5px; border: 1px solid #ddd;background: #ffff;margin:0 2px; font-size:11px; color:#000;}
    .pages a:hover { background-color: #E61636; color:#fff;border:1px solid #E61636; text-decoration:none;}
    .pages .cpb { font-weight: bold; color: #fff; background: #E61636; border:1px solid #E61636;}
    .code{font-weight:bold;color:blue}

  • 相关阅读:
    click事件——背景高亮
    color——RGB转16进制
    导航栏高亮设置
    layui table 渲染完成后,怎样拿到表个里的所有数据
    解决 AttributeError: 'dict' object has no attribute 'has_key' 错误的方法
    2019年总结:醒悟还为时不晚
    Worker Services读取配置后,发布Windows出现的问题及解决
    C# 读取配置(详细操作,让我们一起共同成长)
    程序不包含适合于入口点的静态“Main”方法
    .NET Core3.0-Worker Services
  • 原文地址:https://www.cnblogs.com/520wife/p/2182589.html
Copyright © 2020-2023  润新知