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


C# CheckBox.MergeStyle方法代码示例

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


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

示例1: CreateControlHeirarchy

        protected int CreateControlHeirarchy(IEnumerable dataSource, bool useDataSource)
        {
            // Clear/create the rows ArrayList
            if (this._rows == null)
                this._rows = new ArrayList();
            else
                this._rows.Clear();

            GridViewRow hdr = this.BuildHeader();

            if (this.PageIndex < 0)
                this.PageIndex = 0;
            //int startRec = this.PageIndex * this.PageSize;
            int itemCount = 0; //, recCount = 0;
            if (dataSource != null)
            {
                foreach (var dataItem in dataSource)
                {
                    //if (recCount < startRec || itemCount >= this.PageSize)
                    //{
                    //    recCount++;
                    //    continue;
                    //}

                    GridViewRow tr = new GridViewRow(itemCount + (this.ShowHeader ? 1 : 0), itemCount, DataControlRowType.DataRow, (itemCount % 2 == 0 ? DataControlRowState.Normal : DataControlRowState.Alternate));
                    tr.CssClass = (itemCount % 2 == 0) ? "GridViewLineAlt" : "GridViewLine";

                    TableCell tdL = new TableCell();
                    tdL.CssClass = "GridViewLineLeft";
                    tr.Cells.Add(tdL);

                    int curColCount = 0;
                    for (int i = 0; i < this.Columns.Count; i++)
                    {
                        TableCell td = new TableCell();

                        DataControlField column = this.Columns[i];

                        bool usedTemplate = false;
                        if (column is TemplateField)
                        {
                            TemplateField fld = (column as TemplateField);
                            ITemplate template = null;
                            if (itemCount % 2 != 0)
                                template = fld.AlternatingItemTemplate;
                            if (template == null)
                                template = fld.ItemTemplate;

                            if (template != null)
                            {
                                template.InstantiateIn(td);
                                usedTemplate = true;
                            }
                        }

                        if (!usedTemplate)
                        {
                            string dataStr = string.Empty;
                            if (column is BoundField)
                            {
                                BoundField fld = (column as BoundField);
                                if (!string.IsNullOrEmpty(fld.DataField))
                                    dataStr = DataBinder.GetPropertyValue(dataItem, fld.DataField, fld.DataFormatString);
                                else
                                {
                                    PropertyDescriptorCollection props = TypeDescriptor.GetProperties(dataItem);
                                    if (props.Count >= 1)
                                        if (null != props[0].GetValue(dataItem))
                                            dataStr = props[0].GetValue(dataItem).ToString();
                                }
                            }

                            if (column is CheckBoxField)
                            {
                                CheckBoxField fld = (column as CheckBoxField);
                                CheckBox chkFld = new CheckBox();
                                chkFld.ID = string.Format("chkField_{0}_{1}", itemCount, i);
                                string fldStr = string.Empty;
                                if (!string.IsNullOrEmpty(fld.Text))
                                    fldStr = fld.Text;
                                else if (!string.IsNullOrEmpty(fld.DataField))
                                    fldStr = dataStr;
                                chkFld.Text = fldStr;
                                chkFld.MergeStyle(fld.ControlStyle);
                                td.Controls.Add(chkFld);
                            }
                            else if (column is CommandField)
                            {
                                CommandField fld = (column as CommandField);

                                string keyArg = string.Empty;
                                if (this.DataKeyNames != null && this.DataKeyNames.Length > 0)
                                    keyArg = string.Join(",", this.DataKeyNames);

                                if (fld.ShowSelectButton)
                                {
                                    WebControl btn = this.GetButton(fld, "Select", keyArg, itemCount, i, fld.SelectText, fld.SelectImageUrl);
                                    td.Controls.Add(btn);
                                }

//.........这里部分代码省略.........
开发者ID:tenshino,项目名称:RainstormStudios,代码行数:101,代码来源:GridView.cs


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