public static IDataControlButton CreateButton (ButtonType type, Control container, string text, string image, string command, string commandArg, bool allowCallback)
		{
			IDataControlButton btn;

			switch (type) {
			case ButtonType.Link:
				btn = new DataControlLinkButton ();
				break;
			case ButtonType.Image:
				btn = new DataControlImageButton ();
				btn.ImageUrl = image;
				break;
			default:
				btn = new DataControlButton ();
				break;
			}

			btn.Container = container;
			btn.CommandName = command;
			btn.CommandArgument = commandArg;
			btn.Text = text;
			btn.CausesValidation = false;
			btn.AllowCallback = allowCallback;

			return btn;
		}
Пример #2
0
        public static IDataControlButton CreateButton(ButtonType type, Control container, string text, string image, string command, string commandArg, bool allowCallback)
        {
            IDataControlButton btn;

            switch (type)
            {
            case ButtonType.Link:
                btn = new DataControlLinkButton();
                break;

            case ButtonType.Image:
                btn          = new DataControlImageButton();
                btn.ImageUrl = image;
                break;

            default:
                btn = new DataControlButton();
                break;
            }

            btn.Container        = container;
            btn.CommandName      = command;
            btn.CommandArgument  = commandArg;
            btn.Text             = text;
            btn.CausesValidation = false;
            btn.AllowCallback    = allowCallback;

            return(btn);
        }
        private void AddButtonToCell(DataControlFieldCell cell, string commandName, string buttonText, bool causesValidation, string validationGroup, int rowIndex, string imageUrl)
        {
            IButtonControl     control;
            IPostBackContainer container = base.Control as IPostBackContainer;
            bool flag = true;

            switch (this.ButtonType)
            {
            case ButtonType.Button:
                if ((container == null) || causesValidation)
                {
                    control = new Button();
                }
                else
                {
                    control = new DataControlButton(container);
                    flag    = false;
                }
                break;

            case ButtonType.Link:
                if ((container == null) || causesValidation)
                {
                    control = new DataControlLinkButton(null);
                }
                else
                {
                    control = new DataControlLinkButton(container);
                    flag    = false;
                }
                break;

            default:
                if ((container != null) && !causesValidation)
                {
                    control = new DataControlImageButton(container);
                    flag    = false;
                }
                else
                {
                    control = new ImageButton();
                }
                ((ImageButton)control).ImageUrl = imageUrl;
                break;
            }
            control.Text            = buttonText;
            control.CommandName     = commandName;
            control.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
            if (flag)
            {
                control.CausesValidation = causesValidation;
            }
            control.ValidationGroup = validationGroup;
            cell.Controls.Add((WebControl)control);
        }
        private void AddButtonToCell(DataControlFieldCell cell, string commandName, string buttonText, bool causesValidation, string validationGroup, int rowIndex, string imageUrl)
        {
            IButtonControl control;
            IPostBackContainer container = base.Control as IPostBackContainer;
            bool flag = true;
            switch (this.ButtonType)
            {
                case ButtonType.Button:
                    if ((container == null) || causesValidation)
                    {
                        control = new Button();
                    }
                    else
                    {
                        control = new DataControlButton(container);
                        flag = false;
                    }
                    break;

                case ButtonType.Link:
                    if ((container == null) || causesValidation)
                    {
                        control = new DataControlLinkButton(null);
                    }
                    else
                    {
                        control = new DataControlLinkButton(container);
                        flag = false;
                    }
                    break;

                default:
                    if ((container != null) && !causesValidation)
                    {
                        control = new DataControlImageButton(container);
                        flag = false;
                    }
                    else
                    {
                        control = new ImageButton();
                    }
                    ((ImageButton) control).ImageUrl = imageUrl;
                    break;
            }
            control.Text = buttonText;
            control.CommandName = commandName;
            control.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
            if (flag)
            {
                control.CausesValidation = causesValidation;
            }
            control.ValidationGroup = validationGroup;
            cell.Controls.Add((WebControl) control);
        }
Пример #5
0
        private void AddButtonToCell(DataControlFieldCell cell,  string commandName, string buttonText, bool causesValidation, string validationGroup, int rowIndex, string imageUrl) {
            IButtonControl button;
            IPostBackContainer container = Control as IPostBackContainer;
            bool setCausesValidation = true;    // the setter on the DataControlButtons throw if there's a container for security

            switch (ButtonType) {
                case ButtonType.Link: {
                    if (container != null && !causesValidation) {
                        button = new DataControlLinkButton(container);
                        setCausesValidation = false;
                    }
                    else {
                        button = new DataControlLinkButton(null);
                    }

                    break;
                }
                case ButtonType.Button: {
                    if (container != null && !causesValidation) {
                        button = new DataControlButton(container);
                        setCausesValidation = false;
                    }
                    else {
                        button = new Button();
                    }

                    break;
                }
                case ButtonType.Image:
                default: {
                    if (container != null && !causesValidation) {
                        button = new DataControlImageButton(container);
                        setCausesValidation = false;
                    }
                    else {
                        button = new ImageButton();
                    }

                    ((ImageButton)button).ImageUrl = imageUrl;
                    break;
                }
            }
            
            button.Text = buttonText;
            button.CommandName = commandName;
            button.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
            if (setCausesValidation) {
                button.CausesValidation = causesValidation;
            }
            button.ValidationGroup = validationGroup;

            cell.Controls.Add((WebControl)button);

        }
Пример #6
0
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);
            if ((cellType != DataControlCellType.Header) && (cellType != DataControlCellType.Footer))
            {
                IButtonControl     control;
                IPostBackContainer container = base.Control as IPostBackContainer;
                bool causesValidation        = this.CausesValidation;
                bool flag2 = true;
                switch (this.ButtonType)
                {
                case ButtonType.Button:
                    if ((container == null) || causesValidation)
                    {
                        control = new Button();
                    }
                    else
                    {
                        control = new DataControlButton(container);
                        flag2   = false;
                    }
                    break;

                case ButtonType.Link:
                    if ((container == null) || causesValidation)
                    {
                        control = new DataControlLinkButton(null);
                    }
                    else
                    {
                        control = new DataControlLinkButton(container);
                        flag2   = false;
                    }
                    break;

                default:
                    if ((container != null) && !causesValidation)
                    {
                        control = new DataControlImageButton(container);
                        flag2   = false;
                    }
                    else
                    {
                        control = new ImageButton();
                    }
                    ((ImageButton)control).ImageUrl = this.ImageUrl;
                    break;
                }
                control.Text            = this.Text;
                control.CommandName     = this.CommandName;
                control.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
                if (flag2)
                {
                    control.CausesValidation = causesValidation;
                }
                control.ValidationGroup = this.ValidationGroup;
                if ((this.DataTextField.Length != 0) && base.Visible)
                {
                    ((WebControl)control).DataBinding += new EventHandler(this.OnDataBindField);
                }
                cell.Controls.Add((WebControl)control);
            }
        }
Пример #7
0
        private void AddButtonToCell(DataControlFieldCell cell, string commandName, string buttonText, bool causesValidation, string validationGroup, int rowIndex, string imageUrl)
        {
            IButtonControl     button;
            IPostBackContainer container = Control as IPostBackContainer;
            bool setCausesValidation     = true; // the setter on the DataControlButtons throw if there's a container for security

            switch (ButtonType)
            {
            case ButtonType.Link: {
                if (container != null && !causesValidation)
                {
                    button = new DataControlLinkButton(container);
                    setCausesValidation = false;
                }
                else
                {
                    button = new DataControlLinkButton(null);
                }

                break;
            }

            case ButtonType.Button: {
                if (container != null && !causesValidation)
                {
                    button = new DataControlButton(container);
                    setCausesValidation = false;
                }
                else
                {
                    button = new Button();
                }

                break;
            }

            case ButtonType.Image:
            default: {
                if (container != null && !causesValidation)
                {
                    button = new DataControlImageButton(container);
                    setCausesValidation = false;
                }
                else
                {
                    button = new ImageButton();
                }

                ((ImageButton)button).ImageUrl = imageUrl;
                break;
            }
            }

            button.Text            = buttonText;
            button.CommandName     = commandName;
            button.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
            if (setCausesValidation)
            {
                button.CausesValidation = causesValidation;
            }
            button.ValidationGroup = validationGroup;

            cell.Controls.Add((WebControl)button);
        }
        /// <devdoc>
        /// <para>Initializes a cell in the System.Web.UI.WebControls.Field.</para>
        /// </devdoc>
        public virtual void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) {
            switch (cellType) {
                case DataControlCellType.Header:
                    {
                        WebControl headerControl = null;
                        string sortExpression = SortExpression;
                        bool sortableHeader = (_sortingEnabled && sortExpression.Length > 0);

                        string headerImageUrl = HeaderImageUrl;
                        string headerText = HeaderText;
                        if (headerImageUrl.Length != 0) {
                            if (sortableHeader) {
                                ImageButton sortButton;
                                IPostBackContainer container = _control as IPostBackContainer;
                                if (container != null) {
                                    sortButton = new DataControlImageButton(container);
                                    ((DataControlImageButton)sortButton).EnableCallback(null);  // no command argument for the callback uses Sort
                                }
                                else {
                                    sortButton = new ImageButton();
                                }

                                sortButton.ImageUrl = HeaderImageUrl;
                                sortButton.CommandName = DataControlCommands.SortCommandName;
                                sortButton.CommandArgument = sortExpression;
                                if (!(sortButton is DataControlImageButton)) {
                                    sortButton.CausesValidation = false;
                                }
                                sortButton.AlternateText = headerText;
                                headerControl = sortButton;
                            }
                            else {
                                Image headerImage = new Image();

                                headerImage.ImageUrl = headerImageUrl;
                                headerControl = headerImage;
                                headerImage.AlternateText = headerText;
                            }
                        }
                        else {
                            if (sortableHeader) {
                                LinkButton sortButton;
                                IPostBackContainer container = _control as IPostBackContainer;
                                if (container != null) {
                                    sortButton = new DataControlLinkButton(container);
                                    ((DataControlLinkButton)sortButton).EnableCallback(null);   // no command argument for the callback uses Sort
                                }
                                else {
                                    sortButton = new LinkButton();
                                }

                                sortButton.Text = headerText;
                                sortButton.CommandName = DataControlCommands.SortCommandName;
                                sortButton.CommandArgument = sortExpression;
                                if (!(sortButton is DataControlLinkButton)) {
                                    sortButton.CausesValidation = false;
                                }
                                headerControl = sortButton;
                            }
                            else {
                                if (headerText.Length == 0) {
                                    // the browser does not render table borders for cells with nothing
                                    // in their content, so we add a non-breaking space.
                                    headerText = "&nbsp;";
                                }
                                cell.Text = headerText;
                            }
                        }

                        if (headerControl != null) {
                            cell.Controls.Add(headerControl);
                        }
                    }
                    break;

                case DataControlCellType.Footer:
                    {
                        string footerText = FooterText;
                        if (footerText.Length == 0) {
                            // the browser does not render table borders for cells with nothing
                            // in their content, so we add a non-breaking space.
                            footerText = "&nbsp;";
                        }

                        cell.Text = footerText;
                    }
                    break;
            }
        }
Пример #9
0
        /// <devdoc>
        /// <para>Initializes a cell in the <see cref='System.Web.UI.WebControls.ButtonField'/> .</para>
        /// </devdoc>
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) {
            base.InitializeCell(cell, cellType, rowState, rowIndex);

            if ((cellType != DataControlCellType.Header) &&
                (cellType != DataControlCellType.Footer)) {
                IButtonControl button;
                IPostBackContainer container = Control as IPostBackContainer;
                bool causesValidation = CausesValidation;
                bool setCausesValidation = true;    // the setter on the DataControlButtons throw if there's a container for security

                switch(ButtonType) {
                    case ButtonType.Link: {
                        if (container != null && !causesValidation) {
                            button = new DataControlLinkButton(container);
                            setCausesValidation = false;
                        }
                        else {
                            // use DataControlLinkButton because it uses the right forecolor
                            button = new DataControlLinkButton(null);
                        }
                        break;
                    }
                    case ButtonType.Button: {
                        if (container != null && !causesValidation) {
                            button = new DataControlButton(container);
                            setCausesValidation = false;
                        }
                        else {
                            button = new Button();
                        }
                        break;
                    }
                    case ButtonType.Image:
                    default: {
                        if (container != null && !causesValidation) {
                            button = new DataControlImageButton(container);
                            setCausesValidation = false;
                        }
                        else {
                            button = new ImageButton();
                        }

                        ((ImageButton)button).ImageUrl = ImageUrl;
                        break;
                    }
                }

                button.Text = Text;
                button.CommandName = CommandName;
                button.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
                if (setCausesValidation) {
                    button.CausesValidation = causesValidation;
                }
                button.ValidationGroup = ValidationGroup;
                
                if (DataTextField.Length != 0 && Visible) {
                    ((WebControl)button).DataBinding += new EventHandler(this.OnDataBindField);
                }

                cell.Controls.Add((WebControl)button);
            }
        }
Пример #10
0
		TableCell InitializeNextPrevPager (DataGridItem item, int columnSpan, PagedDataSource paged)
		{
			TableCell res = new TableCell ();
			res.ColumnSpan = columnSpan;

			Control prev;
			Control next;

			if (paged.IsFirstPage) {
				Label l = new Label ();
				l.Text = PagerStyle.PrevPageText;
				prev = l;
			} else {
#if NET_2_0
				LinkButton l = new DataControlLinkButton ();
#else
				LinkButton l = new LinkButton ();
#endif
				l.Text = PagerStyle.PrevPageText;
				l.CommandName = PageCommandName;
				l.CommandArgument = PrevPageCommandArgument;
				l.CausesValidation = false;
				prev = l;
			}

			if (paged.Count > 0 && !paged.IsLastPage) {
#if NET_2_0
				LinkButton l = new DataControlLinkButton ();
#else
				LinkButton l = new LinkButton ();
#endif
				l.Text = PagerStyle.NextPageText;
				l.CommandName = PageCommandName;
				l.CommandArgument = NextPageCommandArgument;
				l.CausesValidation = false;
				next = l;
			} else {
				Label l = new Label ();
				l.Text = PagerStyle.NextPageText;
				next = l;
			}

			res.Controls.Add (prev);
			res.Controls.Add (new LiteralControl ("&nbsp;"));
			res.Controls.Add (next);

			return res;
		}
 public virtual void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
 {
     WebControl control;
     string sortExpression;
     string headerText;
     ImageButton button;
     switch (cellType)
     {
         case DataControlCellType.Header:
         {
             control = null;
             sortExpression = this.SortExpression;
             bool flag = this._sortingEnabled && (sortExpression.Length > 0);
             string headerImageUrl = this.HeaderImageUrl;
             headerText = this.HeaderText;
             if (headerImageUrl.Length == 0)
             {
                 if (flag)
                 {
                     LinkButton button2;
                     IPostBackContainer container2 = this._control as IPostBackContainer;
                     if (container2 != null)
                     {
                         button2 = new DataControlLinkButton(container2);
                         ((DataControlLinkButton) button2).EnableCallback(null);
                     }
                     else
                     {
                         button2 = new LinkButton();
                     }
                     button2.Text = headerText;
                     button2.CommandName = "Sort";
                     button2.CommandArgument = sortExpression;
                     if (!(button2 is DataControlLinkButton))
                     {
                         button2.CausesValidation = false;
                     }
                     control = button2;
                 }
                 else
                 {
                     if (headerText.Length == 0)
                     {
                         headerText = "&nbsp;";
                     }
                     cell.Text = headerText;
                 }
                 goto Label_015C;
             }
             if (!flag)
             {
                 Image image = new Image {
                     ImageUrl = headerImageUrl
                 };
                 control = image;
                 image.AlternateText = headerText;
                 goto Label_015C;
             }
             IPostBackContainer container = this._control as IPostBackContainer;
             if (container == null)
             {
                 button = new ImageButton();
                 break;
             }
             button = new DataControlImageButton(container);
             ((DataControlImageButton) button).EnableCallback(null);
             break;
         }
         case DataControlCellType.Footer:
         {
             string footerText = this.FooterText;
             if (footerText.Length == 0)
             {
                 footerText = "&nbsp;";
             }
             cell.Text = footerText;
             return;
         }
         default:
             return;
     }
     button.ImageUrl = this.HeaderImageUrl;
     button.CommandName = "Sort";
     button.CommandArgument = sortExpression;
     if (!(button is DataControlImageButton))
     {
         button.CausesValidation = false;
     }
     button.AlternateText = headerText;
     control = button;
 Label_015C:
     if (control != null)
     {
         cell.Controls.Add(control);
     }
 }
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);
            if ((cellType != DataControlCellType.Header) && (cellType != DataControlCellType.Footer))
            {
                IButtonControl control;
                IPostBackContainer container = base.Control as IPostBackContainer;
                bool causesValidation = this.CausesValidation;
                bool flag2 = true;
                switch (this.ButtonType)
                {
                    case ButtonType.Button:
                        if ((container == null) || causesValidation)
                        {
                            control = new Button();
                        }
                        else
                        {
                            control = new DataControlButton(container);
                            flag2 = false;
                        }
                        break;

                    case ButtonType.Link:
                        if ((container == null) || causesValidation)
                        {
                            control = new DataControlLinkButton(null);
                        }
                        else
                        {
                            control = new DataControlLinkButton(container);
                            flag2 = false;
                        }
                        break;

                    default:
                        if ((container != null) && !causesValidation)
                        {
                            control = new DataControlImageButton(container);
                            flag2 = false;
                        }
                        else
                        {
                            control = new ImageButton();
                        }
                        ((ImageButton) control).ImageUrl = this.ImageUrl;
                        break;
                }
                control.Text = this.Text;
                control.CommandName = this.CommandName;
                control.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
                if (flag2)
                {
                    control.CausesValidation = causesValidation;
                }
                control.ValidationGroup = this.ValidationGroup;
                if ((this.DataTextField.Length != 0) && base.Visible)
                {
                    ((WebControl) control).DataBinding += new EventHandler(this.OnDataBindField);
                }
                cell.Controls.Add((WebControl) control);
            }
        }
        public virtual void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            WebControl  control;
            string      sortExpression;
            string      headerText;
            ImageButton button;

            switch (cellType)
            {
            case DataControlCellType.Header:
            {
                control        = null;
                sortExpression = this.SortExpression;
                bool   flag           = this._sortingEnabled && (sortExpression.Length > 0);
                string headerImageUrl = this.HeaderImageUrl;
                headerText = this.HeaderText;
                if (headerImageUrl.Length == 0)
                {
                    if (flag)
                    {
                        LinkButton         button2;
                        IPostBackContainer container2 = this._control as IPostBackContainer;
                        if (container2 != null)
                        {
                            button2 = new DataControlLinkButton(container2);
                            ((DataControlLinkButton)button2).EnableCallback(null);
                        }
                        else
                        {
                            button2 = new LinkButton();
                        }
                        button2.Text            = headerText;
                        button2.CommandName     = "Sort";
                        button2.CommandArgument = sortExpression;
                        if (!(button2 is DataControlLinkButton))
                        {
                            button2.CausesValidation = false;
                        }
                        control = button2;
                    }
                    else
                    {
                        if (headerText.Length == 0)
                        {
                            headerText = "&nbsp;";
                        }
                        cell.Text = headerText;
                    }
                    goto Label_015C;
                }
                if (!flag)
                {
                    Image image = new Image {
                        ImageUrl = headerImageUrl
                    };
                    control             = image;
                    image.AlternateText = headerText;
                    goto Label_015C;
                }
                IPostBackContainer container = this._control as IPostBackContainer;
                if (container == null)
                {
                    button = new ImageButton();
                    break;
                }
                button = new DataControlImageButton(container);
                ((DataControlImageButton)button).EnableCallback(null);
                break;
            }

            case DataControlCellType.Footer:
            {
                string footerText = this.FooterText;
                if (footerText.Length == 0)
                {
                    footerText = "&nbsp;";
                }
                cell.Text = footerText;
                return;
            }

            default:
                return;
            }
            button.ImageUrl        = this.HeaderImageUrl;
            button.CommandName     = "Sort";
            button.CommandArgument = sortExpression;
            if (!(button is DataControlImageButton))
            {
                button.CausesValidation = false;
            }
            button.AlternateText = headerText;
            control = button;
Label_015C:
            if (control != null)
            {
                cell.Controls.Add(control);
            }
        }
        /// <devdoc>
        /// <para>Initializes a cell in the System.Web.UI.WebControls.Field.</para>
        /// </devdoc>
        public virtual void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            switch (cellType)
            {
            case DataControlCellType.Header:
            {
                WebControl headerControl  = null;
                string     sortExpression = SortExpression;
                bool       sortableHeader = (_sortingEnabled && sortExpression.Length > 0);

                string headerImageUrl = HeaderImageUrl;
                string headerText     = HeaderText;
                if (headerImageUrl.Length != 0)
                {
                    if (sortableHeader)
                    {
                        ImageButton        sortButton;
                        IPostBackContainer container = _control as IPostBackContainer;
                        if (container != null)
                        {
                            sortButton = new DataControlImageButton(container);
                            ((DataControlImageButton)sortButton).EnableCallback(null);          // no command argument for the callback uses Sort
                        }
                        else
                        {
                            sortButton = new ImageButton();
                        }

                        sortButton.ImageUrl        = HeaderImageUrl;
                        sortButton.CommandName     = DataControlCommands.SortCommandName;
                        sortButton.CommandArgument = sortExpression;
                        if (!(sortButton is DataControlImageButton))
                        {
                            sortButton.CausesValidation = false;
                        }
                        sortButton.AlternateText = headerText;
                        headerControl            = sortButton;
                    }
                    else
                    {
                        Image headerImage = new Image();

                        headerImage.ImageUrl      = headerImageUrl;
                        headerControl             = headerImage;
                        headerImage.AlternateText = headerText;
                    }
                }
                else
                {
                    if (sortableHeader)
                    {
                        LinkButton         sortButton;
                        IPostBackContainer container = _control as IPostBackContainer;
                        if (container != null)
                        {
                            sortButton = new DataControlLinkButton(container);
                            ((DataControlLinkButton)sortButton).EnableCallback(null);           // no command argument for the callback uses Sort
                        }
                        else
                        {
                            sortButton = new LinkButton();
                        }

                        sortButton.Text            = headerText;
                        sortButton.CommandName     = DataControlCommands.SortCommandName;
                        sortButton.CommandArgument = sortExpression;
                        if (!(sortButton is DataControlLinkButton))
                        {
                            sortButton.CausesValidation = false;
                        }
                        headerControl = sortButton;
                    }
                    else
                    {
                        if (headerText.Length == 0)
                        {
                            // the browser does not render table borders for cells with nothing
                            // in their content, so we add a non-breaking space.
                            headerText = "&nbsp;";
                        }
                        cell.Text = headerText;
                    }
                }

                if (headerControl != null)
                {
                    cell.Controls.Add(headerControl);
                }
            }
            break;

            case DataControlCellType.Footer:
            {
                string footerText = FooterText;
                if (footerText.Length == 0)
                {
                    // the browser does not render table borders for cells with nothing
                    // in their content, so we add a non-breaking space.
                    footerText = "&nbsp;";
                }

                cell.Text = footerText;
            }
            break;
            }
        }
Пример #15
0
        /// <devdoc>
        /// <para>Initializes a cell in the <see cref='System.Web.UI.WebControls.ButtonField'/> .</para>
        /// </devdoc>
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);

            if ((cellType != DataControlCellType.Header) &&
                (cellType != DataControlCellType.Footer))
            {
                IButtonControl     button;
                IPostBackContainer container = Control as IPostBackContainer;
                bool causesValidation        = CausesValidation;
                bool setCausesValidation     = true; // the setter on the DataControlButtons throw if there's a container for security

                switch (ButtonType)
                {
                case ButtonType.Link: {
                    if (container != null && !causesValidation)
                    {
                        button = new DataControlLinkButton(container);
                        setCausesValidation = false;
                    }
                    else
                    {
                        // use DataControlLinkButton because it uses the right forecolor
                        button = new DataControlLinkButton(null);
                    }
                    break;
                }

                case ButtonType.Button: {
                    if (container != null && !causesValidation)
                    {
                        button = new DataControlButton(container);
                        setCausesValidation = false;
                    }
                    else
                    {
                        button = new Button();
                    }
                    break;
                }

                case ButtonType.Image:
                default: {
                    if (container != null && !causesValidation)
                    {
                        button = new DataControlImageButton(container);
                        setCausesValidation = false;
                    }
                    else
                    {
                        button = new ImageButton();
                    }

                    ((ImageButton)button).ImageUrl = ImageUrl;
                    break;
                }
                }

                button.Text            = Text;
                button.CommandName     = CommandName;
                button.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
                if (setCausesValidation)
                {
                    button.CausesValidation = causesValidation;
                }
                button.ValidationGroup = ValidationGroup;

                if (DataTextField.Length != 0 && Visible)
                {
                    ((WebControl)button).DataBinding += new EventHandler(this.OnDataBindField);
                }

                cell.Controls.Add((WebControl)button);
            }
        }