Ejemplo n.º 1
0
        private void CreateCustomPagerRow(GridViewRowEventArgs e)
        {
            e.Row.Cells[0].Controls.Clear();
            e.Row.Cells[0].Controls.Add(new LiteralControl("共 "));
            Label child = new Label {
                ID   = "LblRowsCount",
                Text = this.VirtualItemCount.ToString(),
                Font = { Bold = true }
            };

            e.Row.Cells[0].Controls.Add(child);
            e.Row.Cells[0].Controls.Add(new LiteralControl(" " + this.ItemUnit + this.ItemName));
            e.Row.Cells[0].Controls.Add(new LiteralControl("  "));
            LinkButton button = new LinkButton {
                CommandName     = "Page",
                CommandArgument = "First",
                Enabled         = this.PageIndex != 0,
                Text            = "首页"
            };

            e.Row.Cells[0].Controls.Add(button);
            e.Row.Cells[0].Controls.Add(new LiteralControl(" "));
            LinkButton button2 = new LinkButton {
                CommandName     = "Page",
                CommandArgument = "Prev",
                Enabled         = this.PageIndex != 0,
                Text            = "上一页"
            };

            e.Row.Cells[0].Controls.Add(button2);
            e.Row.Cells[0].Controls.Add(new LiteralControl(" "));
            LinkButton button3 = new LinkButton {
                CommandName     = "Page",
                CommandArgument = "Next",
                Enabled         = this.PageIndex != (this.PageCount - 1),
                Text            = "下一页"
            };

            e.Row.Cells[0].Controls.Add(button3);
            e.Row.Cells[0].Controls.Add(new LiteralControl(" "));
            LinkButton button4 = new LinkButton {
                CommandName     = "Page",
                CommandArgument = "Last",
                Enabled         = this.PageIndex != (this.PageCount - 1),
                Text            = "尾页"
            };

            e.Row.Cells[0].Controls.Add(button4);
            e.Row.Cells[0].Controls.Add(new LiteralControl("  "));
            if (this.IsHoldState)
            {
                button.Click  += new EventHandler(this.LbtnFirst_Click);
                button2.Click += new EventHandler(this.LbtnPrev_Click);
                button3.Click += new EventHandler(this.LbtnNext_Click);
                button4.Click += new EventHandler(this.LbtnLast_Click);
            }
            e.Row.Cells[0].Controls.Add(new LiteralControl("页次:"));
            Label label2 = new Label {
                Text      = Convert.ToString((int)(this.PageIndex + 1)),
                Font      = { Bold = true },
                ForeColor = Color.Red
            };

            e.Row.Cells[0].Controls.Add(label2);
            e.Row.Cells[0].Controls.Add(new LiteralControl("/"));
            Label label3 = new Label {
                Text = Convert.ToString(this.PageCount),
                Font = { Bold = true }
            };

            e.Row.Cells[0].Controls.Add(label3);
            e.Row.Cells[0].Controls.Add(new LiteralControl("页"));
            e.Row.Cells[0].Controls.Add(new LiteralControl("  "));
            TextBox box = new TextBox();

            box.ApplyStyleSheetSkin(this.Page);
            box.MaxLength    = 3;
            box.Width        = 0x16;
            box.Text         = Convert.ToString(this.PageSize);
            box.AutoPostBack = true;
            box.TextChanged += new EventHandler(this.TxtMaxPerPage_TextChanged);
            e.Row.Cells[0].Controls.Add(box);
            e.Row.Cells[0].Controls.Add(new LiteralControl(this.ItemUnit + this.ItemName + "/页"));
            e.Row.Cells[0].Controls.Add(new LiteralControl("  "));
            e.Row.Cells[0].Controls.Add(new LiteralControl("转到第"));
            if (this.PageCount < 10)
            {
                DropDownList list = new DropDownList();
                list.ApplyStyleSheetSkin(this.Page);
                list.AutoPostBack          = true;
                list.SelectedIndexChanged += new EventHandler(this.DropCurrentPage_SelectedIndexChanged);
                ArrayList list2 = new ArrayList();
                for (int i = 1; i <= this.PageCount; i++)
                {
                    list2.Add(i);
                }
                list.DataSource = list2;
                list.DataBind();
                list.SelectedIndex = this.PageIndex;
                e.Row.Cells[0].Controls.Add(list);
            }
            else
            {
                TextBox box2 = new TextBox();
                box2.ApplyStyleSheetSkin(this.Page);
                box2.Width        = 30;
                box2.Text         = Convert.ToString((int)(this.PageIndex + 1));
                box2.AutoPostBack = true;
                box2.TextChanged += new EventHandler(this.TxtCurrentPage_TextChanged);
                e.Row.Cells[0].Controls.Add(box2);
            }
            e.Row.Cells[0].Controls.Add(new LiteralControl("页"));
        }