zoukankan      html  css  js  c++  java
  • DataList分页方法一

    SqlConnection conn = new SqlConnection();
                conn.Open();
                SqlDataAdapter da = new SqlDataAdapter(sql, conn);
                DataSet ds = new DataSet();
                da.Fill(ds, "Product_gongqiu");

                PagedDataSource pds = new PagedDataSource();
                pds.DataSource = ds.Tables["Product_gongqiu"].DefaultView;
                //开启分页
                pds.AllowPaging = true;
                //显示显示的行数
                pds.PageSize = 8;
                //定义变量保存当前页索引
                int curPage;

                //判断当前页是否有跳转请求
                if (Request.QueryString["page"] != null)
                    curPage = Convert.ToInt32(Request.QueryString["page"]);
                else
                    curPage = 1;
                pds.CurrentPageIndex = curPage - 1;

                Label1.Text = "当前第" + curPage.ToString() + "页";
                Label2.Text = "共" + pds.PageCount.ToString() + "页";


                if (!pds.IsFirstPage)
                { //定义"上一页"超级连接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引植
                    prev.NavigateUrl = "@@@.aspx?page=" + (curPage - 1) + "&sqltext=" + sql + "&tiaojiantext=" + tiaojian;
                }
                if (!pds.IsLastPage)
                { //下一页
                    next.NavigateUrl = "@@@.aspx?page=" + (curPage + 1) + "&sqltext=" + sql + "&tiaojiantext=" + tiaojian;
                }

                DataList1.DataSource = pds;
                DataList1.DataBind();

  • 相关阅读:
    二进制状态压缩对应 bool 数组中的常用操作
    [Acwing 327] 玉米田 题解
    [CF Contest] Web of Lies 题解
    ArchLinux安装vscode
    ArchLinux安装并且配置fcitx5
    【日常训练】取数问题
    Oracle sql 转 Hive sql一些语法问题
    Oracle中的connect by 转成hive的 lateral view explode
    Hive之分析函数
    数据仓库之拉链表设计
  • 原文地址:https://www.cnblogs.com/maoyu417/p/1073684.html
Copyright © 2011-2022 走看看