Ejemplo n.º 1
0
        /// <summary>
        ///  Display a graphic image for the Sort Order along with the sort sequence no.
        /// </summary>
        protected void DisplaySortOrderImages(string dataSortExpr, GridViewRow viewRow)
        {
            for (int i = 0; i < viewRow.Cells.Count; i++)
            {
                if (Columns[i].SortExpression == SortExpression &&
                    viewRow.Cells[i].Controls.Count > 0 &&
                    viewRow.Cells[i].Controls[0] is LinkButton)
                {
                    var sortImgLoc = (SortDirection == SortDirection.Ascending ? SortAscImageUrl : SortDescImageUrl);

                    if (!string.IsNullOrEmpty(sortImgLoc))
                    {
                        var imgSortDirection = new ImageEx
                        {
                            AutoDetectSize = true,
                            ImageUrl       = sortImgLoc
                        };
                        viewRow.Cells[i].Controls.Add(imgSortDirection);
                    }
                    else
                    {
                        Label lblSortDirection = new Label();
                        lblSortDirection.Font.Size     = FontUnit.XSmall;
                        lblSortDirection.Font.Name     = "webdings";
                        lblSortDirection.EnableTheming = false;
                        lblSortDirection.Text          = (SortDirection == SortDirection.Ascending ? "5" : "6");
                        viewRow.Cells[i].Controls.Add(lblSortDirection);
                    }

                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            if (Mode != ButtonType.Link)
            {
                return;
            }

            string imageUrl = ImageUrl;

            if (!string.IsNullOrEmpty(imageUrl))
            {
                var image = new ImageEx
                {
                    ImageUrl       = imageUrl,
                    AlternateText  = ToolTip,
                    ImageAlign     = ImageAlign,
                    AutoDetectSize = true
                };

                Controls.Add(image);
            }

            //string text = Text;
            //if (!string.IsNullOrEmpty(text))
            //{
            //    Literal literal = new Literal();
            //    if (hasImage)
            //        literal.Text = " " + text;
            //    else
            //        literal.Text = text;
            //    Controls.Add(literal);
            //}
        }