zoukankan      html  css  js  c++  java
  • asp.net gridview 分页

    //分页初始化
                btnFirst.Enabled = true;
                btnPrev.Enabled = true;
                btnNext.Enabled = true;
                btnLast.Enabled = true;
    
                LblCurrentIndex.Visible = true;
                LblPageCount.Visible = true;
                LblRecordCount.Visible = true;
                LblCurrentIndex.Text = "" + (PlatformsGridView.PageIndex + 1).ToString() + "";
                LblPageCount.Text = "" + PlatformsGridView.PageCount.ToString() + "";
                LblRecordCount.Text = "总共 " + list.Count() + "";
    
                //如果Gridview的行数位0
                if (PlatformsGridView.Rows.Count == 0)
                {
                    btnFirst.Enabled = false;
                    btnPrev.Enabled = false;
                    btnNext.Enabled = false;
                    btnLast.Enabled = false;
    
                    LblCurrentIndex.Visible = false;
                    LblPageCount.Visible = false;
                    LblRecordCount.Visible = false;
                }
    
                //如果Gridview的页数为1
                else if (PlatformsGridView.PageCount == 1)
                {
                    btnFirst.Enabled = false;
                    btnPrev.Enabled = false;
                    btnNext.Enabled = false;
                    btnLast.Enabled = false;
                }
                //如果Gridview的页数大于1
                else if (PlatformsGridView.PageCount > 1)
                {
                    if (PlatformsGridView.PageIndex == 0)
                    {
                        btnFirst.Enabled = false;
                        btnPrev.Enabled = false;
                        btnNext.Enabled = true;
                        btnLast.Enabled = true;
                    }
                    else if (PlatformsGridView.PageIndex == PlatformsGridView.PageCount - 1)
                    {
                        btnFirst.Enabled = true;
                        btnPrev.Enabled = true;
                        btnNext.Enabled = false;
                        btnLast.Enabled = false;
                    }
                    else
                    {
                        btnFirst.Enabled = true;
                        btnPrev.Enabled = true;
                        btnNext.Enabled = true;
                        btnLast.Enabled = true;
                    }
    
                }
    
                // 计算生成分页页码,分别为:"首 页" "上一页" "下一页" "尾 页"
                btnFirst.CommandName = "1";
                btnPrev.CommandName = (PlatformsGridView.PageIndex == 0 ? "1" : PlatformsGridView.PageIndex.ToString());
    
                btnNext.CommandName = (PlatformsGridView.PageCount == 1 ? PlatformsGridView.PageCount.ToString() : (PlatformsGridView.PageIndex + 2).ToString());
                btnLast.CommandName = PlatformsGridView.PageCount.ToString();
  • 相关阅读:
    使用Charles对iPhone进行Http(s)请求拦截(抓包)
    pip 安装 和 卸载 django
    python2.7.5 安装pip
    (Git 学习)Git SSH Key 创建步骤
    git学习四:eclipse使用git提交项目
    我们为什么要使用List和Set(List,Set详解)
    List、Set、Map的区别
    type=hidden
    测试业务分析
    USACO 3.2 kimbits DP
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3075920.html
Copyright © 2011-2022 走看看