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();
  • 相关阅读:
    [编程题] 微信红包
    MYSQL实现主从复制
    有关windows系统的EXE和DLL文件说法错误
    Http错误代码
    一步步优化JVM四:决定Java堆的大小以及内存占用
    一步步优化JVM三:GC优化基础
    一步步优化JVM二:JVM部署模型和JVM Runtime
    一步步优化JVM一:概述、方法及需求
    排查Java线上服务故障的方法和实例分析
    【转】Zookeeper-Watcher机制与异步调用原理
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3075920.html
Copyright © 2011-2022 走看看