zoukankan      html  css  js  c++  java
  • girdview 分页PageIndexChanging

    修改方法:一要在girdview 后面加 OnPageIndexChanging="GridView1_PageIndexChanging

                    二要cs页面中添加

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

        {

            GridView1.PageIndex = e.NewPageIndex;

            DataBind();

        }

     OK问题解决!!

      下面的是一个比较齐全的分页代码, 

     protected void Page_Load(object sender, EventArgs e)

        {

            btnFirst.Text = "最首页";

            btnPrev.Text = "前一页";

            btnNext.Text = "下一页";

            btnLast.Text = "最后页";

            GridView1.DataBind();

            ShowPageChangedStatus();

        }

       private void ShowPageChangedStatus()

        {

            lblCurrentIndex.Text = "第" + (GridView1.PageIndex + 1).ToString() + "页";

            lblPageCount.Text = "总共 " + GridView1.PageCount.ToString() + " 页";

        }

        public void PagerButtonClick(object sender, EventArgs e)

        {

            string arg = ((LinkButton)sender).CommandArgument.ToString();

            switch (arg)

            {

                case "next":

                    if (GridView1.PageIndex < (GridView1.PageCount - 1))

                    {

                        GridView1.PageIndex += 1;

                    }

                    break;

                case "prev":

                    if (GridView1.PageIndex > 0)

                    {

                        GridView1.PageIndex -= 1;

                    }

                    break;

                case "last":

                    GridView1.PageIndex = (GridView1.PageCount - 1);

                    break;

                default:

                    GridView1.PageIndex = System.Convert.ToInt32(arg);

                    break;

            }

            GridView1.DataBind();

            ShowPageChangedStatus();

        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

        {

            int startIndex;

            startIndex = GridView1.PageIndex * GridView1.PageSize;

            GridView1.PageIndex = e.NewPageIndex;

            GridView1.DataBind();

            ShowPageChangedStatus();

        }

     


      <asp:label id="lblPageCount" runat="server"></asp:label>&nbsp;

      <asp:label id="lblCurrentIndex" runat="server"></asp:label>

      <asp:linkbutton id="btnFirst" onclick="PagerButtonClick" runat="server"

       Font-size="8pt" ForeColor="navy" CommandArgument="0"></asp:linkbutton>&nbsp;

      <asp:linkbutton id="btnPrev" onclick="PagerButtonClick" runat="server"

       Font-size="8pt" ForeColor="navy" CommandArgument="prev"></asp:linkbutton>&nbsp;

      <asp:linkbutton id="btnNext" onclick="PagerButtonClick" runat="server"

       Font-size="8pt" ForeColor="navy" CommandArgument="next"></asp:linkbutton>&nbsp;

      <asp:linkbutton id="btnLast" onclick="PagerButtonClick" runat="server"

       Font-size="8pt" ForeColor="navy" CommandArgument="last"></asp:linkbutton>

  • 相关阅读:
    N75终于可以发彩信了
    用OpenSSL编写SSL,TLS程序(转)
    分享 jdk ant 绿色安装及自动化配置 for windows
    Symbian: How to write HBufC* to file(转)
    [转载]用非对称密码算法制作共享软件的注册码
    [笔记]远程终端API,Terminal Services Administration
    [转载]共享软件的注册加密法
    [希腊神话] 3Apollo(阿波罗,太阳神) [English Edition][附译文]
    [转载]软件加密技术和注册机制
    [希腊神话] 5Nereus and Proteus(纳鲁斯和普鲁吐斯,海神) [English Edition][附译文]
  • 原文地址:https://www.cnblogs.com/tonybinlj/p/1448504.html
Copyright © 2011-2022 走看看