Пример #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// InstantiateIn instantiates the template (implementation of ITemplate)
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="container">The parent container (DataGridItem)</param>
        /// -----------------------------------------------------------------------------
        public void InstantiateIn(Control container)
        {
            switch (ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:
            case ListItemType.SelectedItem:
            case ListItemType.EditItem:
                if (EditMode == ImageCommandColumnEditMode.URL)
                {
                    var hypLink = new HyperLink();
                    hypLink.ToolTip = Text;
                    if (!String.IsNullOrEmpty(ImageURL) && ShowImage)
                    {
                        var img = new Image();
                        if (DesignMode)
                        {
                            img.ImageUrl = ImageURL.Replace("~/", "../../");
                        }
                        else
                        {
                            img.ImageUrl = ImageURL;
                        }
                        hypLink.Controls.Add(img);
                        img.ToolTip = Text;
                    }
                    else
                    {
                        hypLink.Text = Text;
                    }
                    hypLink.DataBinding += Item_DataBinding;
                    container.Controls.Add(hypLink);
                }
                else
                {
                    if (!String.IsNullOrEmpty(ImageURL) && ShowImage)
                    {
                        var colIcon = new ImageButton();
                        if (DesignMode)
                        {
                            colIcon.ImageUrl = ImageURL.Replace("~/", "../../");
                        }
                        else
                        {
                            colIcon.ImageUrl = ImageURL;
                        }
                        colIcon.ToolTip = Text;
                        if (!String.IsNullOrEmpty(OnClickJS))
                        {
                            ClientAPI.AddButtonConfirm(colIcon, OnClickJS);
                        }
                        colIcon.CommandName  = CommandName;
                        colIcon.DataBinding += Item_DataBinding;
                        container.Controls.Add(colIcon);
                    }
                    if (!String.IsNullOrEmpty(Text) && !ShowImage)
                    {
                        var colLink = new LinkButton();
                        colLink.ToolTip = Text;
                        if (!String.IsNullOrEmpty(OnClickJS))
                        {
                            ClientAPI.AddButtonConfirm(colLink, OnClickJS);
                        }
                        colLink.CommandName  = CommandName;
                        colLink.Text         = Text;
                        colLink.DataBinding += Item_DataBinding;
                        container.Controls.Add(colLink);
                    }
                }
                break;

            case ListItemType.Footer:
            case ListItemType.Header:
                container.Controls.Add(new LiteralControl(Text));
                break;
            }
        }