// Add Edit and Delete columns
            private void AddWorkerColumns()
            {
                if (ShowWebdings)
                {
                    EditColumnText       = "/";
                    EditColumnUpdateText = "R";
                    EditColumnCancelText = "T";
                    DeleteColumnText     = "r";
                }

                // Edit column
                EditCommandColumn editColumn = new EditCommandColumn();

                editColumn.EditText   = EditColumnText;
                editColumn.UpdateText = EditColumnUpdateText;
                editColumn.CancelText = EditColumnCancelText;
                if (ShowWebdings)
                {
                    editColumn.ItemStyle.Font.Size = 11;
                    editColumn.ItemStyle.Font.Name = "wingdings 2";
                }
                Columns.Add(editColumn);


                // Delete column
                ButtonColumn deleteColumn = new ButtonColumn();

                deleteColumn.CommandName = "delete";
                deleteColumn.Text        = DeleteColumnText;
                if (ShowWebdings)
                {
                    deleteColumn.ItemStyle.Font.Name = "webdings";
                }
                Columns.Add(deleteColumn);
            }
Example #2
0
        /// <summary>
        /// OnInit() method -- Add the Edit and Delete columns to the grid
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            // Test for Page to ensure this doesn't run at design time
            if (Page != null)
            {
                string imagePath = GetClientScriptPath();

                EditCommandColumn c0 = new EditCommandColumn();
                c0.EditText   = "<img src='" + imagePath + "edit.gif' border=0 alt='" + General.GetString("XMLEDITGRID_EDITITEM", "edit this item") + "'>";
                c0.CancelText = "<img src='" + imagePath + "cancel.gif' border=0 alt='" + General.GetString("XMLEDITGRID_CANCEL", "cancel") + "'>";
                c0.UpdateText = "<img src='" + imagePath + "update.gif' border=0 alt='" + General.GetString("XMLEDITGRID_SAVE", "save changes") + "'>";
                c0.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                c0.HeaderStyle.Width         = new Unit("35px");
                this.Columns.Add(c0);

                ButtonColumn c1 = new ButtonColumn();
                c1.CommandName = "Delete";
                c1.Text        = "<img src='" + imagePath + "delete.gif' border=0 alt='" + General.GetString("XMLEDITGRID_DELETE", "delete this item") + "'>";
                c1.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                c1.HeaderStyle.Width         = new Unit("35px");
                this.Columns.Add(c1);

                this.ShowFooter = true;
                this.ItemStyle.VerticalAlign = VerticalAlign.Top;
            }
        }
Example #3
0
        private DataGridColumn c_edit()
        {
            EditCommandColumn column1 = new EditCommandColumn();

            column1.EditText = "Edit";
            return(column1);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //string filePath = this.MapPath(Application["ReportXMLPosition"].ToString() + LanguageManager.LanguageXml);
            //this.Session["ChangePriceForFPLCalcLanguage"] = Language.GetLanguage(filePath, "ChangePriceForFPLCalc");
            this.grid.Columns[0].HeaderText = this.GetLanguage("Instrument");   //"Item";
            this.grid.Columns[1].HeaderText = this.GetLanguage("Code");         //"Code";
            this.grid.Columns[2].HeaderText = this.GetLanguage("Bid");          //"Bid";
            this.grid.Columns[3].HeaderText = this.GetLanguage("Ask");          //"Ask";
            this.grid.Columns[4].HeaderText = this.GetLanguage("SpreadPoints"); //"SpreadPoints";

            EditCommandColumn operationColumn = (EditCommandColumn)this.grid.Columns[5];

            operationColumn.HeaderText = this.GetLanguage("Operation"); //"Operation";
            operationColumn.EditText   = this.GetLanguage("Modify");    //"Modify";

            this.saveButton.Text        = this.GetLanguage("SaveButton");
            this._ChangePriceTitle.Text = this.GetLanguage("ChangePriceTitle");

            // Put user code to initialize the page here
            if (Page.IsPostBack)
            {
                return;
            }
            this.DataBind();
        }
        private DataGridColumn c_edit(bool v)
        {
            EditCommandColumn column1 = new EditCommandColumn();

            column1.EditText = "Edit";
            column1.Visible  = v;
            return(column1);
        }
        private DataGridColumn c_edit(string se)
        {
            EditCommandColumn column1 = new EditCommandColumn();

            column1.EditText       = "Edit";
            column1.SortExpression = se;
            return(column1);
        }
Example #7
0
        private DataGridColumn c_edit(string se)
        {
            EditCommandColumn column1 = new EditCommandColumn();

            column1.EditText       = "Edit";
            column1.HeaderImageUrl = se;
            return(column1);
        }
        private DataGridColumn c_edit(ListItemType tp, string text)
        {
            EditCommandColumn column1 = new EditCommandColumn();

            column1.EditText = "Edit";
            this.setStyle(column1, tp);
            this.setText(column1, tp, text);
            return(column1);
        }
Example #9
0
        public void ThisIsADGTest()
        {
            DataGridTest      p     = new DataGridTest();
            DataTable         table = new DataTable();
            EditCommandColumn e;
            string            markup;

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.LinkButton;
            e.CancelText = "Cancel";
            e.EditText   = "Edit";
            e.UpdateText = "Update";

            table.Columns.Add(new DataColumn("one", typeof(string)));
            table.Columns.Add(new DataColumn("two", typeof(string)));
            table.Columns.Add(new DataColumn("three", typeof(string)));
            table.Rows.Add(new object [] { "1", "2", "3" });

            p.DataSource = new DataView(table);
            p.Columns.Add(e);

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.PushButton;
            e.CancelText = "Abbrechen";
            e.EditText   = "Bearbeiten";
            e.UpdateText = "Refresh";
            p.Columns.Add(e);

            p.CreateControls(true);
            // This is the test we want to run: setting the ID of the table created by
            // the datagrid overrides the using the ID of the datagrid itself and uses
            // the table ClientID instead.
            p.ID = "sucker";
            p.Controls [0].ID = "tbl";

            Assert.AreEqual(2, p.Columns.Count, "I1");
            markup = ControlMarkup(p.Controls[0]);
            markup = markup.Replace("\t", "");
            markup = markup.Replace("\r", "");
            markup = markup.Replace("\n", "");

#if NET_2_0
            HtmlDiff.AssertAreEqual(
                "<table border=\"0\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
                "</tr><tr><td><a>Edit</a></td><td><input name=\"sucker_tbl$ctl02$ctl00\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" +
                "</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
                "</tr></table>", markup, "I2");
#else
            Assert.AreEqual(
                "<table border=\"0\" id=\"sucker_tbl\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
                "</tr><tr><td><a>Edit</a></td><td><input name=\"sucker:_ctl1:_ctl0\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" +
                "</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
                "</tr></table>", markup, "I2");
#endif
        }
Example #10
0
        public void AddEditColumn()
        {
            EditCommandColumn cmdColumn = new EditCommandColumn();

            cmdColumn.EditText             = "Edit";
            cmdColumn.UpdateText           = "Update";
            cmdColumn.CancelText           = "Cancel";
            cmdColumn.HeaderText           = "<strong>Actions</strong>";
            cmdColumn.HeaderStyle.CssClass = "ms-TPHeader";
            cmdColumn.ItemStyle.CssClass   = "ms-alternating";
            this.Columns.Add(cmdColumn);
        }
Example #11
0
        public void InitializeCell()
        {
            DataGridTest      p     = new DataGridTest();
            DataTable         table = new DataTable();
            EditCommandColumn e;
            string            markup;

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.LinkButton;
            e.CancelText = "Cancel";
            e.EditText   = "Edit";
            e.UpdateText = "Update";

            table.Columns.Add(new DataColumn("one", typeof(string)));
            table.Columns.Add(new DataColumn("two", typeof(string)));
            table.Columns.Add(new DataColumn("three", typeof(string)));
            table.Rows.Add(new object [] { "1", "2", "3" });

            p.DataSource = new DataView(table);
            p.Columns.Add(e);

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.PushButton;
            e.CancelText = "Abbrechen";
            e.EditText   = "Bearbeiten";
            e.UpdateText = "Refresh";
            p.Columns.Add(e);

            // This will trigger EditCommandColumn.InitializeCell, without any EditItem set, tests the EditText render
            p.CreateControls(true);
            p.ID = "sucker";

            Assert.AreEqual(2, p.Columns.Count, "I1");
            markup = ControlMarkup(p.Controls[0]);
            markup = markup.Replace("\t", "");
            markup = markup.Replace("\r", "");
            markup = markup.Replace("\n", "");

#if NET_2_0
            HtmlDiff.AssertAreEqual(
                "<table border=\"0\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
                "</tr><tr><td><a>Edit</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" +
                "</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
                "</tr></table>", markup, "I2");
#else
            Assert.AreEqual(
                "<table border=\"0\" id=\"sucker\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
                "</tr><tr><td><a>Edit</a></td><td><input name=\"sucker:_ctl1:_ctl0\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" +
                "</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
                "</tr></table>", markup, "I2");
#endif
            //ShowControlsRecursive (p.Controls [0], 1);
        }
        public void InitializeReadOnlyEditCell()
        {
            DataGridTest      p     = new DataGridTest();
            DataTable         table = new DataTable();
            EditCommandColumn e;
            string            markup;

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.LinkButton;
            e.CancelText = "Cancel";
            e.EditText   = "Edit";
            e.UpdateText = "Update";

            table.Columns.Add(new DataColumn("one", typeof(string)));
            table.Columns.Add(new DataColumn("two", typeof(string)));
            table.Columns.Add(new DataColumn("three", typeof(string)));
            table.Rows.Add(new object[] { "1", "2", "3" });

            p.DataSource = new DataView(table);
            p.Columns.Add(e);

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.PushButton;

            e.CancelText = "Abbrechen";
            e.EditText   = "Bearbeiten";
            e.UpdateText = "Refresh";
            p.Columns.Add(e);

            // Force the ListItemType to be EditItem so we can test rendering the UpdateText/CancelText render
            p.EditItemIndex = 0;

            // This will trigger EditCommandColumn.InitializeCell
            p.CreateControls(true);
            p.ID = "sucker";

            markup = ControlMarkup(p.Controls[0]);
            markup = markup.Replace("\t", "");
            markup = markup.Replace("\r", "");
            markup = markup.Replace("\n", "");

            Assert.AreEqual(2, p.Columns.Count, "I1");
            Assert.AreEqual(
                "<table border=\"0\" id=\"sucker\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
                "</tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name type=\"submit\" value=\"Refresh\" />&nbsp;" +
                "<input name value=\"Abbrechen\" type=\"submit\" /></td>" +
                "<td><input name=\"_ctl2:_ctl0\" type=\"text\" value=\"1\" /></td>" +
                "<td><input name=\"_ctl2:_ctl1\" type=\"text\" value=\"2\" /></td>" +
                "<td><input name=\"_ctl2:_ctl2\" type=\"text\" value=\"3\" /></td>" +
                "</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
                "</tr></table>", markup, "I2");
        }
        public void Defaults()
        {
            EditCommandColumn e;

            e = new EditCommandColumn();

            Assert.AreEqual(ButtonColumnType.LinkButton, e.ButtonType, "D1");
            Assert.AreEqual(string.Empty, e.CancelText, "D2");
            Assert.AreEqual(string.Empty, e.EditText, "D3");
            Assert.AreEqual(string.Empty, e.UpdateText, "D4");
            Assert.AreEqual(true, e.CausesValidation, "CausesValidation");
            Assert.AreEqual(string.Empty, e.ValidationGroup, "ValidationGroup");
        }
Example #14
0
        /// <summary>
        /// 加载编辑列
        /// </summary>
        public void LoadEditColumn()
        {
            EditCommandColumn ecc = new EditCommandColumn();//更新按钮列

            ecc.SortExpression        = "desc";
            ecc.ButtonType            = ButtonColumnType.LinkButton;//链接按钮
            ecc.EditText              = "编辑";
            ecc.UpdateText            = "更新";
            ecc.CancelText            = "取消";
            ecc.ItemStyle.Width       = 70;
            ecc.ItemStyle.BorderWidth = 1;
            ecc.ItemStyle.BorderStyle = BorderStyle.Solid;
            ecc.ItemStyle.BorderColor = System.Drawing.Color.FromArgb(234, 233, 225);
            this.Columns.AddAt(0, ecc);//增加按钮列
        }
Example #15
0
        public void LoadEditColumn()
        {
            EditCommandColumn editCommandColumn = new EditCommandColumn();

            editCommandColumn.SortExpression        = "desc";
            editCommandColumn.ButtonType            = ButtonColumnType.LinkButton;
            editCommandColumn.EditText              = "编辑";
            editCommandColumn.UpdateText            = "更新";
            editCommandColumn.CancelText            = "取消";
            editCommandColumn.ItemStyle.Width       = 70;
            editCommandColumn.ItemStyle.BorderWidth = 1;
            editCommandColumn.ItemStyle.BorderStyle = BorderStyle.Solid;
            editCommandColumn.ItemStyle.BorderColor = Color.FromArgb(234, 233, 225);
            this.Columns.AddAt(0, editCommandColumn);
        }
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
            dgrCPD.Columns[2].HeaderText = ResourceManager.GetString("profile_name");
            dgrCPD.Columns[3].HeaderText = ResourceManager.GetString("current_period");
            dgrCPD.Columns[4].HeaderText = ResourceManager.GetString("future_period");
            dgrCPD.Columns[5].HeaderText = ResourceManager.GetString("status");
            dgrCPD.Columns[6].HeaderText = ResourceManager.GetString("action");
            EditCommandColumn ecc = (EditCommandColumn)dgrCPD.Columns[6];

            ecc.EditText = ResourceManager.GetString("edit");
        }
Example #17
0
 protected void InitEditCommandColumn(bool image, ButtonColumnType type, string cancelText, string editText, string headerText, string footerText, string locationImage, string sort, string updateText, bool visible)
 {
     System.Web.UI.WebControls.EditCommandColumn column = new EditCommandColumn();
     column.ButtonType = type;
     column.CancelText = cancelText;
     column.EditText   = editText;
     column.FooterText = footerText;
     column.HeaderText = headerText;
     if (image)
     {
         column.HeaderImageUrl = locationImage;
     }
     column.SortExpression = sort;
     column.UpdateText     = updateText;
     column.Visible        = visible;
 }
        public void Properties()
        {
            EditCommandColumn e;

            e = new EditCommandColumn();

            e.ButtonType = ButtonColumnType.PushButton;
            Assert.AreEqual(ButtonColumnType.PushButton, e.ButtonType, "P1");

            e.CancelText = "Cancel this!";
            Assert.AreEqual("Cancel this!", e.CancelText, "D2");

            e.EditText = "Edit me good";
            Assert.AreEqual("Edit me good", e.EditText, "D3");

            e.UpdateText = "Update? What update?";
            Assert.AreEqual("Update? What update?", e.UpdateText, "D4");
            e.CausesValidation = false;
            Assert.AreEqual(false, e.CausesValidation, "CausesValidation");
            e.ValidationGroup = "test";
            Assert.AreEqual("test", e.ValidationGroup, "ValidationGroup");
        }
Example #19
0
        protected override void OnInit(EventArgs e)
        {
            if (Page != null)
            {
                EditCommandColumn c0 = new EditCommandColumn();
                c0.EditText   = "<img src='/i/edit.gif' border=0 alt='edit this item'>";
                c0.CancelText = "<img src='/i/cancel.gif' border=0 alt=cancel>";
                c0.UpdateText = "<img src='/i/update.gif' border=0 alt='save changes'>";
                c0.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                c0.HeaderStyle.Width         = new Unit("35px");
                this.Columns.Add(c0);

                ButtonColumn c1 = new ButtonColumn();
                c1.CommandName = "Delete";
                c1.Text        = "<img src='/i/delete.gif' border=0 alt='delete this item'>";
                c1.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                c1.HeaderStyle.Width         = new Unit("35px");
                this.Columns.Add(c1);

                this.ShowFooter = true;
                this.ItemStyle.VerticalAlign = VerticalAlign.Top;
            }
        }
Example #20
0
// <Snippet1>
    void Page_Load(Object sender, EventArgs e)
    {
        EditCommandColumn editcolumn = new EditCommandColumn();
    }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //程序模块权限验证
                Authorization clsRighter = new Authorization("0609");
                btnAdd.Enabled = clsRighter.Modify | clsRighter.Add;
                if (clsRighter.Read)
                {
                    //创建操作员记录数据表类实例
                    QuestionOperate question = new QuestionOperate();
                    //获取记录数据
                    DataTable dt = question.ShowQuestion();
                    DataRow   df = dt.NewRow();
                    df["UserName"] = "******";
                    dt.Rows.InsertAt(df, 0);
                    ddlQues.DataSource     = dt;
                    ddlQues.DataTextField  = "UserName";
                    ddlQues.DataValueField = "UserId";
                    ddlQues.DataBind();

                    //控制前台的“编辑”“回复”的显示方式
                    //DBManager db = DBManager.Instance();//通用数据操作类
                    //string sql = db.GetValue("select GroupId from Sys_User where UserId='" + Session["UserID"].ToString() + "'").ToString();
                    //int count = int.Parse(sql);
                    ButtonColumn      sel  = (ButtonColumn)GoodsDataGrid.Columns[8];
                    EditCommandColumn edit = (EditCommandColumn)GoodsDataGrid.Columns[6];
                    if (Session["UserGroupID"].ToString() != "2" && Session["UserGroupID"].ToString() != "3")
                    {
                        sel.Visible         = true;
                        edit.Visible        = false;
                        this.btnAdd.Visible = false;
                    }
                    else
                    {
                        sel.Visible           = false;
                        edit.Visible          = true;
                        this.btnAdd.Visible   = true;
                        ddlQues.SelectedValue = Session["UserID"].ToString();
                        ddlQues.Enabled       = false;
                    }

                    BindDataGrid();


                    int icount = this.GoodsDataGrid.Columns.Count;
                    if (!clsRighter.Add)
                    {
                        this.btnAdd.Visible = false;
                    }
                    //if (!clsRighter.Modify)
                    //{
                    //    this.GoodsDataGrid.Columns[icount - 2].Visible = false;
                    //}
                    if (!clsRighter.Delete)
                    {
                        this.GoodsDataGrid.Columns[icount - 2].Visible = false;
                    }
                }
            }
        }
Example #22
0
    public void Page_Load(object sender, EventArgs e)
    {
        nfi.NumberDecimalSeparator = ".";
        string constr = Global.connstr;

        //String spojeni = ConfigurationSettings.AppSettings[0]; //mozne nastaveni ve web.config
        dt1  = new DataTable();
        dt2  = new DataTable();
        conn = new SqlConnection(constr);
        conn.Open();

        using (var comm = conn.CreateCommand())
        {
            SelectTable(comm);
        }

        dt1.Columns["Id"].ReadOnly = true;
        dtv1 = new DataView(dt1);
        dtv2 = new DataView(dt2);


        Button but = new Button();

        but.Text = "Pridat radek";
        but.ID   = "BUTTON1";
        //Button1 = FindControl("BUTTON1") as Button;
        //Button1.Click += Button1_Click;
        but.Click += Button1_Click;


        EditCommandColumn edcol = new EditCommandColumn();

        edcol.EditText         = "Oprava";
        edcol.CancelText       = "Unik";
        edcol.UpdateText       = "Ulozeni";
        edcol.ItemStyle.Wrap   = false;
        edcol.HeaderStyle.Wrap = false;
        ButtonColumn butcol = new ButtonColumn();

        butcol.ButtonType  = ButtonColumnType.LinkButton;
        butcol.Text        = "Smazat";
        butcol.CommandName = "Delete";


        DataGrid1 = FindControl("DataGrid11") as DataGrid;
        DataGrid1.Columns.Add(edcol);
        DataGrid1.Columns.Add(butcol);
        Form.Controls.Add(but);

        DataGrid1.EditCommand +=
            new DataGridCommandEventHandler(this.ItemsGrid_Edit);
        DataGrid1.CancelCommand +=
            new DataGridCommandEventHandler(this.ItemsGrid_Cancel);
        DataGrid1.UpdateCommand +=
            new DataGridCommandEventHandler(this.ItemsGrid_Update);
        DataGrid1.ItemCommand +=
            new DataGridCommandEventHandler(this.ItemsGrid_Command);
        DataGrid1.AllowSorting = true;


        DataGrid1.DataSource = dt1;
        DataGrid1.DataBind();


        //DataGrid2 = FindControl("DataGrid22") as DataGrid;
        DataGrid2             = new DataGrid();
        DataGrid2.Style.Value = "position:absolute;top:10%;left:50%";
        DataGrid1.Parent.Controls.Add(DataGrid2);
        DataGrid2.DataSource = dt2;
        DataGrid2.DataBind();
    }
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     EditCommandColumn edit = new EditCommandColumn();
 }
        public void InitializeEditCell()
        {
#if NET_4_0
            string origHtml = "<table><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Refresh\" />&nbsp;<input name=\"sucker$ctl02$ctl01\" type=\"submit\" value=\"Abbrechen\" /></td><td><input name=\"sucker$ctl02$ctl02\" type=\"text\" value=\"1\" /></td><td><input name=\"sucker$ctl02$ctl03\" type=\"text\" value=\"2\" /></td><td><input name=\"sucker$ctl02$ctl04\" type=\"text\" value=\"3\" /></td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
#else
            string origHtml = "<table border=\"0\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Refresh\" />&nbsp;<input name=\"sucker$ctl02$ctl01\" type=\"submit\" value=\"Abbrechen\" /></td><td><input name=\"sucker$ctl02$ctl02\" type=\"text\" value=\"1\" /></td><td><input name=\"sucker$ctl02$ctl03\" type=\"text\" value=\"2\" /></td><td><input name=\"sucker$ctl02$ctl04\" type=\"text\" value=\"3\" /></td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
#endif
            DataGridTest      p     = new DataGridTest();
            DataTable         table = new DataTable();
            EditCommandColumn e;
            string            markup;

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.LinkButton;
            e.CancelText = "Cancel";
            e.EditText   = "Edit";
            e.UpdateText = "Update";

            table.Columns.Add(new DataColumn("one", typeof(string)));
            table.Columns.Add(new DataColumn("two", typeof(string)));
            table.Columns.Add(new DataColumn("three", typeof(string)));
            table.Rows.Add(new object [] { "1", "2", "3" });

            p.DataSource = new DataView(table);
            p.Columns.Add(e);

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.PushButton;
            e.CancelText = "Abbrechen";
            e.EditText   = "Bearbeiten";
            e.UpdateText = "Refresh";
            p.Columns.Add(e);

            // Force the ListItemType to be EditItem so we can test rendering the UpdateText/CancelText render
            p.EditItemIndex = 0;

            // This will trigger EditCommandColumn.InitializeCell
            p.CreateControls(true);
            p.ID = "sucker";

            StringBuilder sb = new StringBuilder();
            GetHierarchy(p.Controls, 0, sb);
            string h = sb.ToString();
            int    x = h.IndexOf(".TextBox");
            // These are from the BoundColumns
            Assert.IsTrue(x != -1, "textbox1");
            x = h.IndexOf(".TextBox", x + 1);
            Assert.IsTrue(x != -1, "textbox2");
            x = h.IndexOf(".TextBox", x + 1);
            Assert.IsTrue(x != -1, "textbox3");
            x = h.IndexOf(".TextBox", x + 1);
            Assert.IsTrue(x == -1, "textbox-end");

            markup = ControlMarkup(p.Controls[0]);
            markup = markup.Replace("\t", "");
            markup = markup.Replace("\r", "");
            markup = markup.Replace("\n", "");

//Console.WriteLine("Markup:>{0}<", markup);
            Assert.AreEqual(2, p.Columns.Count, "I1");

            HtmlDiff.AssertAreEqual(origHtml, markup, "I2");
        }
        public static void Validation_Load(Page p)
        {
            string       testType = (string)WebTest.CurrentTest.UserData;
            DataGridTest dg       = new DataGridTest();

            dg.ID = "mygrid";
            EditCommandColumn e;

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.LinkButton;
            e.CancelText = "Cancel";
            e.EditText   = "Edit";
            e.UpdateText = "Update";

            switch (testType)
            {
            case "ValidatingValid":
            case "ValidatingInvalid":
            case "ValidationGroupIncluded":
            case "ValidationGroupNotIncluded":
                e.CausesValidation = true;
                break;

            case "NotValidatingInvalid":
                e.CausesValidation = false;
                break;
            }

            switch (testType)
            {
            case "ValidationGroupIncluded":
            case "ValidationGroupNotIncluded":
                e.ValidationGroup = "Group1";
                break;

            default:
                e.ValidationGroup = "";
                break;
            }

            dg.Columns.Add(e);

            TextBox tb = new TextBox();

            tb.ID = "Text1";
            switch (testType)
            {
            case "ValidatingValid":
                tb.Text = "111";
                break;

            case "ValidatingInvalid":
            case "NotValidatingInvalid":
            case "ValidationGroupIncluded":
            case "ValidationGroupNotIncluded":
                tb.Text = "";
                break;
            }

            RequiredFieldValidator v = new RequiredFieldValidator();

            v.ControlToValidate = "Text1";
            switch (testType)
            {
            case "ValidationGroupIncluded":
                v.ValidationGroup = "Group1";
                break;

            case "ValidationGroupNotIncluded":
                v.ValidationGroup = "NotGroup1";
                break;

            default:
                v.ValidationGroup = "";
                break;
            }
            TemplateColumn tc = new TemplateColumn();

            tc.EditItemTemplate = new ValidatingEditTemplate(tb, v);
            dg.Columns.Add(tc);

            ObjectDataSource ods = new ObjectDataSource("MyObjectDS", "Select");

            ods.UpdateMethod       = "Update";
            ods.DataObjectTypeName = "MyObjectDS";
            ods.ID = "MyDS";

            p.Form.Controls.Add(ods);

            dg.DataSource = ods;
            //dg.DataKeyField = "i";

            //DataTable table = new DataTable ();
            //table.Columns.Add (new DataColumn ("one", typeof (string)));
            //table.Columns.Add (new DataColumn ("two", typeof (string)));
            //table.Columns.Add (new DataColumn ("three", typeof (string)));
            //table.Rows.Add (new object [] { "1", "2", "3" });

            //dg.DataSource = new DataView (table);

            dg.EditItemIndex = 0;
            p.Form.Controls.Add(dg);

            dg.DataBind();
            if (!p.IsPostBack)
            {
                WebTest.CurrentTest.UserData = dg.Items [0].Cells [0].Controls [0].UniqueID;
            }
        }