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


C# TableRow.ApplyStyle方法代码示例

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


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

示例1: DisplayItem

        public virtual void DisplayItem(Table table, IConfigurationElement element, string index, IBinder binder, ITemplatingItem item, TableItemStyle style, TableItemStyle invalidStyle, Dictionary<string, Control> registry, WebPartManager manager)
        {
            string[] span = null;
            if (element.Attributes.ContainsKey("span") && null != element.GetAttributeReference("span").Value)
                span = element.GetAttributeReference("span").Value.ToString().Split(new char[] { ',' });

            string[] rowspan = null;
            if (element.Attributes.ContainsKey("rowspan") && null != element.GetAttributeReference("rowspan").Value)
                rowspan = element.GetAttributeReference("rowspan").Value.ToString().Split(new char[] { ',' });

            TableRow tr = new TableRow();
            tr.ID = string.Concat(new string[]
            {
                table.ID,
                "-",
                element.ConfigKey,
                "-",
                index
            });
            tr.Attributes["key"] = element.ConfigKey;
            tr.ApplyStyle(style);
            foreach (IConfigurationElementAttribute attribute in element.Attributes.Values)
            {
                if ("span" != attribute.ConfigKey && "rowspan" != attribute.ConfigKey)
                {
                    tr.Style.Add(attribute.ConfigKey, attribute.Value.ToString());
                }
            }
            table.Rows.Add(tr);
            int count = 0;
            foreach (IConfigurationElement controlElement in element.Elements.Values)
            {
                TableCell tc = new TableCell();
                tc.ID = tr.ID + "-" + controlElement.ConfigKey;
                tc.Attributes["key"] = controlElement.ConfigKey;
                if (span != null && span.Length > count)
                {
                    int columnSpan = 1;
                    int.TryParse(span[count], out columnSpan);
                    tc.ColumnSpan = columnSpan;

                    if (rowspan != null && rowspan.Length > count)
                    {
                        int rowSpan = 1;
                        int.TryParse(rowspan[count], out rowSpan);
                        tc.RowSpan = rowSpan;
                    }
                    count++;
                }
                tr.Cells.Add(tc);
                string pullpush = null;
                foreach (IConfigurationElement propertyElement in controlElement.Elements.Values)
                {
                    if (propertyElement.Attributes.ContainsKey("for") && "cell" == propertyElement.GetAttributeReference("for").Value.ToString() && propertyElement.Attributes.ContainsKey("member") && propertyElement.Attributes.ContainsKey("value"))
                    {
                        try
                        {
                            ReflectionServices.SetValue(tc, propertyElement.GetAttributeReference("member").Value.ToString(), propertyElement.GetAttributeReference("value").Value);
                        }
                        catch (Exception ex)
                        {
                            ControlFactory.Instance.Monitor.Register(ControlFactory.Instance, ControlFactory.Instance.Monitor.NewEventInstance("set cell attributes error", null, ex, EVENT_TYPE.Error));
                        }
                    }
                    if (propertyElement.Attributes.ContainsKey("pull"))
                    {
                        pullpush = propertyElement.GetAttributeReference("pull").Value.ToString();
                    }
                    else
                    {
                        if (propertyElement.Attributes.ContainsKey("push"))
                        {
                            pullpush = propertyElement.GetAttributeReference("push").Value.ToString();
                        }
                    }
                }
                Control cellControl = ControlFactory.Instance.CreateControl(controlElement, index, binder, item, tc, invalidStyle, registry, manager);
                if (null != cellControl)
                {
                    cellControl.ID = string.Concat(new string[]
                    {
                        table.ID,
                        "-",
                        element.ConfigKey,
                        "-",
                        index,
                        "-",
                        controlElement.ConfigKey,
                        "-ctrl"
                    });
                    tc.Controls.Add(cellControl);
                    if (cellControl is BaseDataBoundControl && !string.IsNullOrEmpty(pullpush))
                    {
                        if (!item.BoundControls.ContainsKey(pullpush))
                        {
                            item.BoundControls.Add(pullpush, new List<BaseDataBoundControl>());
                        }
                        item.BoundControls[pullpush].Add((BaseDataBoundControl)cellControl);
                    }
                }
//.........这里部分代码省略.........
开发者ID:t1b1c,项目名称:lwas,代码行数:101,代码来源:TableTemplateBase.cs


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