zoukankan      html  css  js  c++  java
  • gridview 分页

       protected void PageButtonClick(object sender, EventArgs e)
        {
            LinkButton clickedButton = ((LinkButton)sender);
            if (clickedButton.CommandName == "first")
            {
                gvshow.PageIndex = 0;
            }
            else if (clickedButton.CommandName == "next")
            {
                if (gvshow.PageIndex < gvshow.PageCount - 1)
                {
                    gvshow.PageIndex += 1;
                }
            }
            else if (clickedButton.CommandName == "previous")
            {
                if (gvshow.PageIndex >= 1)
                {
                    gvshow.PageIndex -= 1;
                }
            }
            else if (clickedButton.CommandName == "last")
            {
                gvshow.PageIndex = gvshow.PageCount - 1;
            }
            BindData();
        }   

    protected void gvshow_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Pager)
            {
                Label label_Index = new Label();
                LinkButton Button_IndexFirst = new LinkButton();
                LinkButton Button_IndexLast = new LinkButton();
                LinkButton Button_IndexNext = new LinkButton();
                LinkButton Button_IndexPrevious = new LinkButton();

                Button_IndexFirst.Text = "第一页 ";
                Button_IndexFirst.CommandName = "first";
                Button_IndexFirst.ForeColor = System.Drawing.Color.Blue;
                Button_IndexFirst.Click += new EventHandler(PageButtonClick);

                Button_IndexNext.Text = "  下一页 ";
                Button_IndexNext.CommandName = "next";
                Button_IndexNext.ForeColor = System.Drawing.Color.Blue;

                Button_IndexNext.Click += new EventHandler(PageButtonClick);

                Button_IndexPrevious.Text = "上一页 ";
                Button_IndexPrevious.CommandName = "previous";
                Button_IndexPrevious.ForeColor = System.Drawing.Color.Blue;
                Button_IndexPrevious.Click += new EventHandler(PageButtonClick);

                Button_IndexLast.Text = "最末页 ";
                Button_IndexLast.CommandName = "last";
                Button_IndexLast.ForeColor = System.Drawing.Color.Blue;
                Button_IndexLast.Click += new EventHandler(PageButtonClick);

                label_Index.Text = "当前为第" + (gvshow.PageIndex + 1) + "页,共有" + ((GridView)sender).PageCount + "页";
                e.Row.Controls[0].Controls[0].Controls[0].Controls[0].Controls.AddAt(0, (Button_IndexFirst));
                e.Row.Controls[0].Controls[0].Controls[0].Controls[0].Controls.AddAt(1, (Button_IndexPrevious));

                int controlTmp = e.Row.Controls[0].Controls[0].Controls[0].Controls.Count - 1;
                e.Row.Controls[0].Controls[0].Controls[0].Controls[controlTmp].Controls.Add(Button_IndexNext);
                e.Row.Controls[0].Controls[0].Controls[0].Controls[controlTmp].Controls.Add(Button_IndexLast);

                e.Row.Controls[0].Controls[0].Controls[0].Controls[controlTmp].Controls.Add(label_Index);

                //e.Row.Controls[0].Controls.Add(label_Index);
            }
        }

  • 相关阅读:
    一款非常好用的范围滑动插件
    设置滚动条样式
    Qml 定义 constant
    qml 中 使用 shader
    Qt ImageProvider 的使用
    qt 汉化 国际化
    qt rcc 使用
    CentOS7/RHEL7 pacemaker+corosync高可用集群搭建
    Ubunt平台Qt出现:-1: error: cannot find -lgl
    排序-堆排序
  • 原文地址:https://www.cnblogs.com/lgxll/p/2811595.html
Copyright © 2011-2022 走看看