private void AddActionLinksOnDataBind()
        {
            if (HaveValidActions())
            {
                Validator.ThrowInvalidIf(!Page.EnableViewState, "ActionLinksRequireViewState");

                ActionTemplate actionTemplate = new ActionTemplate(this);

                TemplateField fld = new TemplateField();
                fld.HeaderText =
                    (_actionHeaderText == null) ? "" : _actionHeaderText;
                fld.ItemTemplate = actionTemplate;

                this.gridView.Columns.Add(fld);
            }
        }
        internal void AddActionLinksToContainer(
            Control container,
            int rowIndex,
            ActionTemplate actionTemplate)
        {
            string linkSpacer = _actionSpacer;
            if (linkSpacer == null)
            {
                linkSpacer = " ";
            }

            for (int i = 0; i < _actionLabels.Length; ++i)
            {
                if (i > 0)
                {
                    Literal litSpacer = new Literal();
                    litSpacer.Text = linkSpacer;
                    container.Controls.Add(litSpacer);
                }

                LinkButton link = new LinkButton();
                link.CausesValidation = false;
                link.EnableViewState = true;
                link.Text = _actionLabels[i];
                link.CommandName = _actionCommands[i];
                link.Command += new CommandEventHandler(HandleAction);

                if (_clientActionFunction != null)
                {
                    link.OnClientClick =
                        "return(" + _clientActionFunction +
                        "(event,'" + _actionCommands[i] + "','[KEY]'));";
                }

                if (actionTemplate != null)
                {
                    // data binding ... pick up from there
                    link.DataBinding +=
                        new EventHandler(actionTemplate.OnLinkDataBinding);
                }
                else
                {
                    // restoring from view state ... pick up from DataKeys
                    string key =
                        this.gridView.DataKeys[rowIndex].Value.ToString();

                    link.CommandArgument = key;

                    if (!String.IsNullOrEmpty(link.OnClientClick))
                    {
                        link.OnClientClick =
                            link.OnClientClick.Replace("[KEY]", key);
                    }
                }

                container.Controls.Add(link);
            }
        }