当前位置: 首页>>代码示例>>C#>>正文


C# TableCell.HasControls方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.TableCell.HasControls方法的典型用法代码示例。如果您正苦于以下问题:C# TableCell.HasControls方法的具体用法?C# TableCell.HasControls怎么用?C# TableCell.HasControls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.TableCell的用法示例。


在下文中一共展示了TableCell.HasControls方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderInnerControlContent

        private static void RenderInnerControlContent(TableCell tableCell, ExportCell cell)
        {
            if (!tableCell.HasControls())
            {
                return;
            }

            using (var writer = new StringWriter())
            using (var html = new HtmlTextWriter(writer))
            {
                tableCell.Controls.OfType<Control>()
                    .Where(c => c.Visible)
                    .Where(c => !(c is HiddenField))
                    .ForEach(c => SetContent(c, cell, html));

                cell.Markup += writer.ToString();
            }

            cell.Text += HtmlTagRegex.Replace(cell.Markup, String.Empty);
        }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:20,代码来源:ExportFromTable.cs

示例2: SetGridViewSortImages

        public static void SetGridViewSortImages(object sender, GridViewRowEventArgs e, string sortExpression, string sortDirection, ImageClickEventHandler ascClickEventHandler, ImageClickEventHandler descClickEventHandler, string ascImageFilePath, string descImageFilePage, string headerTextCssClass)
        {
            if (e.Row != null && e.Row.RowType == DataControlRowType.Header)
            {
                int i = 0;
                foreach (TableCell tc in e.Row.Cells)
                {
                    if (tc.HasControls() || (tc.Text != string.Empty && tc.Text.Trim() != "&nbsp;"))
                    {
                        Table table = new Table(), imageTable = new Table();
                        table.CellPadding = 0;
                        table.CellSpacing = 0;
                        table.Style.Add(HtmlTextWriterStyle.VerticalAlign, "middle");
                        table.Attributes.Add("summary", "Header cell structual table");
                        imageTable.CellSpacing = 0;
                        imageTable.CellPadding = 0;
                        imageTable.Attributes.Add("summary", "Sort images structual table");
                        table.BorderStyle = BorderStyle.None;
                        imageTable.BorderStyle = BorderStyle.None;
                        TableRow row = null, AscImageRow, DescImageRow;
                        TableCell AscImageCell, DescImageCell, headerTextCell, imagesCell;

                        AscImageRow = new TableRow();
                        AscImageRow.BackColor = Color.Transparent;
                        AscImageCell = new TableCell();
                        AscImageCell.BorderWidth = new Unit(0);
                        AscImageCell.Style.Add(HtmlTextWriterStyle.Padding, "0");
                        AscImageCell.Style.Add(HtmlTextWriterStyle.Margin, "0");
                        AscImageRow.Cells.Add(AscImageCell);

                        DescImageRow = new TableRow();
                        DescImageRow.BackColor = Color.Transparent;
                        DescImageCell = new TableCell();
                        DescImageCell.BorderWidth = new Unit(0);
                        DescImageCell.Style.Add(HtmlTextWriterStyle.Padding, "0");
                        DescImageCell.Style.Add(HtmlTextWriterStyle.Margin, "0");
                        DescImageRow.Cells.Add(DescImageCell);

                        imagesCell = new TableCell();
                        imagesCell.Width = new Unit(1);
                        imagesCell.BorderWidth = new Unit(0);
                        imagesCell.Style.Add(HtmlTextWriterStyle.Padding, "0");
                        imagesCell.Style.Add(HtmlTextWriterStyle.Margin, "0");
                        imagesCell.Controls.Add(imageTable);

                        row = new TableRow();
                        row.BackColor = Color.Transparent;

                        headerTextCell = new TableCell();
                        headerTextCell.BorderWidth = new Unit(0);
                        headerTextCell.Style.Add(HtmlTextWriterStyle.Padding, "0");
                        headerTextCell.Style.Add(HtmlTextWriterStyle.Margin, "0");
                        headerTextCell.HorizontalAlign = HorizontalAlign.Left;
                        Label HeaderLabel = new Label();
                        HeaderLabel.CssClass = headerTextCssClass;
                        headerTextCell.Controls.Add(HeaderLabel);

                        if (tc.HasControls())
                        {
                            // search for the header link
                            LinkButton lnk = tc.Controls[0] as LinkButton;
                            if (lnk != null)
                            {
                                ImageButton imgBtnUp = new ImageButton();
                                ImageButton imgBtnDown = new ImageButton();
                                imgBtnUp.ID = "imgAsc" + i.ToString();
                                imgBtnDown.ID = "imgDesc" + i.ToString();
                                i++;
                                imgBtnUp.Click += new ImageClickEventHandler(ascClickEventHandler);
                                imgBtnDown.Click += new ImageClickEventHandler(descClickEventHandler);
                                imgBtnUp.CommandName = lnk.CommandName;
                                imgBtnDown.CommandName = lnk.CommandName;
                                imgBtnUp.CommandArgument = lnk.CommandArgument;
                                imgBtnDown.CommandArgument = lnk.CommandArgument;

                                //--set the properties
                                HeaderLabel.Text = lnk.Text.Trim();

                                imgBtnUp.ImageUrl = ascImageFilePath;
                                imgBtnUp.AlternateText = "ascending";
                                imgBtnDown.ImageUrl = descImageFilePage;
                                imgBtnDown.AlternateText = "descending";

                                //// checking if the header link is the user's choice
                                if (sortExpression != lnk.CommandArgument || sortDirection == "DESC")
                                {
                                    AscImageCell.Controls.Add(imgBtnUp);
                                    imageTable.Rows.Add(AscImageRow);
                                }
                                if (sortExpression != lnk.CommandArgument || sortDirection == "ASC")
                                {
                                    DescImageCell.Controls.Add(imgBtnDown);
                                    imageTable.Rows.Add(DescImageRow);
                                }

                                //--this will remove the clickable column header link button that is automatically created
                                //--when adding sorting capabilities to a gridview
                                tc.Controls.RemoveAt(0);

                                if (!AscImageCell.HasControls())
//.........这里部分代码省略.........
开发者ID:jmptrader,项目名称:WebFrameworkMVC,代码行数:101,代码来源:GridViewUtil.cs


注:本文中的System.Web.UI.WebControls.TableCell.HasControls方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。