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();
  • 相关阅读:
    系统知识点
    JS 字符串编码函数(解决URL特殊字符传递问题):escape()、encodeURI()、encodeURIComponent()区别详解
    C# 对文本文件的读写
    ASP.NET Cookie
    ASP.NET MVC之文件下载
    Dictionary、KeyValuePair、Hashtable的比较和使用
    如何引用 System.Runtime.Serialization.Json
    Javascript限制多行文本输入框的字符数
    Javascript中创建字符串的new语法和literal语法
    个人介绍
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3075920.html
Copyright © 2011-2022 走看看