zoukankan      html  css  js  c++  java
  • 给GridView分页

     private void Bind()
        {
            GV1.DataSource = newsbll.SelectNews();
            GV1.DataBind();
            //分页
            int pageAll = Convert.ToInt32(GV1.PageCount.ToString());
            this.LblCurrentIndex.Text = "第 " + (GV1.PageIndex + 1).ToString() + " 页";
            this.LblPageCount.Text = "共 " + pageAll + " 页";
            // 计算生成分页页码,分别为:"首 页" "上一页" "下一页" "尾 页"
            btnFirst.CommandName = "1";
            btnPrev.CommandName = (GV1.PageIndex == 0 ? "1" : GV1.PageIndex.ToString());
            btnNext.CommandName = (GV1.PageCount == 1 ? pageAll.ToString() : (GV1.PageIndex + 2).ToString());
            btnLast.CommandName = pageAll.ToString();
            ddlpage.Items.Clear();
            if (pageAll > 1)
            {
                for (int i = 1; i <= pageAll; i++)
                {
                    ddlpage.Items.Add(new ListItem("" + i, "" + i));
                }
                ddlpage.Items.FindByValue((GV1.PageIndex + 1).ToString()).Selected = true;
                ddlpage.Visible = true;
                noinfodiv.Visible = false;
                pagediv.Visible = true;
            }
            else if (pageAll == 1)
            {
                pagediv.Visible = false;
                noinfodiv.Visible = false;
            }
            else
            {
                pagediv.Visible = false;
                noinfodiv.Visible = true;
            }
        }

     /// <summary>
        /// 分页 上一页 下一页 首页 尾页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PagerButtonClick(object sender, EventArgs e)
        {
            GV1.PageIndex = Convert.ToInt32(((LinkButton)sender).CommandName) - 1;

            Bind();

        }
        /// <summary>
        /// 转页面dorpListDown
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlpage_SelectedIndexChanged(object sender, EventArgs e)
        {
            GV1.PageIndex = Convert.ToInt32(ddlpage.SelectedValue) - 1;
            ddlpage.SelectedIndex = GV1.PageIndex;
            Bind();
        }

  • 相关阅读:
    asp.net大文件(视频)分片上传
    numpy.argmin
    python-Numpy学习之(一)ndim、shape、dtype、astype的用法
    matlab设置小数位数
    利用Open3D进行点云可视化
    dell5820参数
    CUDA与cuDNN
    Ubuntu16.04更换cudnn版本
    二进制格式保存文件np.save和np.load-Numpy数组的保存与读取方法
    python pickle存储、读取大数据量列表、字典数据的方法
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/1769365.html
Copyright © 2011-2022 走看看