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();
  • 相关阅读:
    iOS UITextField 设置内边距
    在网页中嵌入任意字体的解决方案
    基数等比,确定进制
    改善CSS编码的5个在线幻灯片教程
    head区的代码详解
    一个简单的、循序渐进的CSS幻灯片教程
    功能强大易用的Web视频播放器——Flowplayer(使用方法及演示)
    CSS:区分IE版本的三个方法
    CSS书写标准及最佳实践
    Sliding Photograph Galleries
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3075920.html
Copyright © 2011-2022 走看看