• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# WebControls.ListControl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ListControl类属于System.Web.UI.WebControls命名空间,在下文中一共展示了ListControl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Fillchk

 public static void Fillchk(ListControl control, string key, string value, object data)
 {
     control.DataSource = data;
     control.DataValueField = key;
     control.DataTextField = value;
     control.DataBind();
 }
开发者ID:Antoniotoress1992,项目名称:asp,代码行数:7,代码来源:ucNewLead.ascx.cs


示例2: McssWebQuestion

 public McssWebQuestion(string strId, bool bRequired, string strRequiredText, string strQuestion, string strControlBase, RepeatDirection rdLayout, string[] strResponses)
     : base(strId, "mcss", bRequired, strRequiredText, strQuestion)
 {
     this.m_radioButtonList = new RadioButtonList();
     this.m_dropDownList = new DropDownList();
     this.m_listControl = null;
     if (strControlBase == "dropdown")
     {
         this.m_listControl = this.m_dropDownList;
     }
     else
     {
         this.m_radioButtonList.RepeatDirection = rdLayout;
         this.m_listControl = this.m_radioButtonList;
     }
     foreach (string text in strResponses)
     {
         this.m_listControl.Items.Add(new ListItem(text));
     }
     this.m_listControl.ID = "lst_" + strId;
     if (bRequired)
     {
         ListControlValidator child = new ListControlValidator();
         child.EnableClientScript = false;
         child.Text = strRequiredText;
         child.Display = ValidatorDisplay.Dynamic;
         child.ControlToValidate = this.m_listControl.ID;
         this.Controls.Add(child);
     }
     this.Controls.Add(this.m_listControl);
     this.Controls.Add(new LiteralControl("</p>"));
 }
开发者ID:italiazhuang,项目名称:wx_ptest,代码行数:32,代码来源:McssWebQuestion.cs


示例3: PopulateListControl2

        public new void PopulateListControl2(ListControl listControl)
        {
            var filterAttribute = Column.GetAttribute<FilterForeignKeyAttribute>();
               if (filterAttribute == null || Session[filterAttribute.SessionVariableName] == null)
               {
                    base.PopulateListControl(listControl);
                    return;
               }

               var context = Column.Table.CreateContext();
               var foreignKeyTable = ForeignKeyColumn.ParentTable;
               var filterColumn = foreignKeyTable.GetColumn(filterAttribute.FilterColumnName);
               var value = Convert.ChangeType(Session[filterAttribute.SessionVariableName].ToString(), filterColumn.TypeCode, CultureInfo.InvariantCulture);

               var query = foreignKeyTable.GetQuery(context); // Get Column Value query
               var entityParam = Expression.Parameter(foreignKeyTable.EntityType, foreignKeyTable.Name); // get the table entity to be filtered
               var property = Expression.Property(entityParam, filterColumn.Name); // get the property to be filtered
               var equalsCall = Expression.Equal(property, Expression.Constant(value)); // get the equal call
               var whereLambda = Expression.Lambda(equalsCall, entityParam); // get the where lambda
               var whereCall = Expression.Call(typeof(Queryable), "Where", new Type[] { foreignKeyTable.EntityType }, query.Expression, whereLambda); // get the where call
               var values = query.Provider.CreateQuery(whereCall);
               foreach (var row in values)
               {
                    listControl.Items.Add(new ListItem()
                    {
                         Text = foreignKeyTable.GetDisplayString(row),
                         Value = foreignKeyTable.GetPrimaryKeyString(row)
                    });
               }
        }
开发者ID:weavver,项目名称:weavver,代码行数:30,代码来源:Enumeration_Edit.ascx.cs


示例4: ListPropertyBinding

 /// <summary>
 /// Constructs a new list property binding for the given ListControl element.
 /// </summary>
 /// <param name="list">The list control to be bound to the data property.</param>
 protected ListPropertyBinding(ListControl list)
     : base(list)
 {
     bool isMultiVal = control is ListBox || control is CheckBoxList;
     // ListBox and CheckBoxList post values on selection change, since deselecting all has no post value
     // and we have to use selection change to detect this as opposed to no post at all
     if (isMultiVal)
     {
         PostedValue = null;
         list.SelectedIndexChanged += delegate
         {
             if (isMultiVal && property != null && control.Page != null)
             {
                 PostedValue = control.Page.Request.Form[control.UniqueID] ?? "";
                 // for CheckBoxList each item is posted individually, so we just reconstruct it
                 // from the selected item, since LoadPostData should have happened by now.
                 if (control is CheckBoxList)
                 {
                     List<string> newValues = new List<string>();
                     foreach (ListItem item in list.Items)
                         if (item.Selected && !newValues.Contains(item.Value)) newValues.Add(item.Value);
                     PostedValue = string.Join(",", newValues.ToArray());
                 }
                 UpdateProperty(PostedValue);
             }
         };
     }
 }
开发者ID:Xomega-Net,项目名称:XomegaFramework,代码行数:32,代码来源:ListPropertyBinding.cs


示例5: FillRange

 public static void FillRange(ListControl control, int min = 1, int max = 10)
 {
     control.DataSource = GetRange(min, max);
     control.DataValueField = "key";
     control.DataTextField = "value";
     control.DataBind();
 }
开发者ID:Antoniotoress1992,项目名称:asp,代码行数:7,代码来源:CollectionManager.cs


示例6: PopulateListControl

        /// <summary>
        /// Populate a ListControl with all the items in the foreign table
        /// </summary>
        /// <param name="listControl"></param>
        /// <param name="dataSource"></param>
        /// <parm name="valueField"></parm>
        /// <parm name="defaultTextField"></parm>
        protected void PopulateListControl(ListControl listControl, IQueryable dataSource, string valueField)
        {
            var filterdata = new List<KeyValuePair<string, string>>();
            string textField = string.Empty;

            if (dataSource != null)
            {
                if (_filterFields.ForeignText != string.Empty)
                {
                    if (CheckDropDownTextField(_filterFields.ForeignText, dataSource.ElementType)) {
                        textField = _filterFields.ForeignText;
                    }
                }

                if (textField == string.Empty) {
                    textField = FindDropDownTextField(Column.FieldName, dataSource.ElementType);
                }

                foreach (object dataItem in dataSource) {
                    filterdata.Add(new KeyValuePair<string, string>(DataBinder.GetPropertyValue(dataItem, textField, null), DataBinder.GetPropertyValue(dataItem, valueField, null)));
                }

                if (_filterFields.SortField == "Yes")
                {
                    if (_filterFields.SortDescending)
                        filterdata.Sort(CompareDesc);
                    else
                        filterdata.Sort(CompareAsc);
                }

                foreach (KeyValuePair<string, string> keyvalue in filterdata) {
                    listControl.Items.Add(new ListItem(keyvalue.Key, _filterFields.FieldName + ":" + keyvalue.Value));
                }
            }
        }
开发者ID:jbwilliamson,项目名称:MaximiseWFScaffolding,代码行数:42,代码来源:ScaffoldFilterUserControl.cs


示例7: Flip

 public static void Flip(Label lbl, ListControl lst, bool blnReadOnly)
 {
     lbl.Visible = blnReadOnly;
     lst.Visible = !blnReadOnly;
     if (blnReadOnly)
     {
         lbl.Text = "";
         foreach (ListItem item in lst.Items)
         {
             if (item.Selected)
             {
                 lbl.Text = lbl.Text + "<br>" + item.Text;
             }
         }
         if (lbl.Text != "")
         {
             lbl.Text = lbl.Text.Remove(0, 4);
         }
     }
     else
     {
         string str = lbl.Text.Replace("<br>", ",");
         if (str != "")
         {
             foreach (string str2 in str.Split(new char[] { ',' }))
             {
                 SelectedByText(lst, str2);
             }
         }
     }
 }
开发者ID:wjkong,项目名称:MicNets,代码行数:31,代码来源:WebHelper.cs


示例8: GetSelectedInt

		public static int? GetSelectedInt(ListControl ddl) {
			int? iVal = null;
			if (ddl.SelectedItem != null) {
				iVal = int.Parse(ddl.SelectedValue);
			}
			return iVal;
		}
开发者ID:tridipkolkata,项目名称:CarrotCakeCMS,代码行数:7,代码来源:GeneralUtilities.cs


示例9: Bind2Ddl

 public static void Bind2Ddl(ListControl ddl, DataTable dt, string textField, string valueField)
 {
     ddl.DataSource = dt;
     ddl.DataTextField = textField;
     ddl.DataValueField = valueField;
     ddl.DataBind();
 }
开发者ID:jon0638,项目名称:simeria,代码行数:7,代码来源:Database.cs


示例10: BindList

 public static void BindList(ListControl _ltControl, bool _bIncludeSel, bool _bIncludeAll, bool _bIncludeTip)
 {
     if (null != _ltControl)
     {
         _ltControl.Items.Clear();
         if (_bIncludeAll)
         {
             _ltControl.Items.Add(new ListItem("--全部--", ""));
         }
         if (_bIncludeSel)
         {
             _ltControl.Items.Add(new ListItem("--请选择--", ""));
         }
         SystemRole[] alist = SystemRole.List();
         if (alist != null && alist.Length != 0)
         {
             SystemRole[] array = alist;
             for (int i = 0; i < array.Length; i++)
             {
                 SystemRole item = array[i];
                 ListItem li = new ListItem(item.Name, string.Concat(item.Id));
                 if (_bIncludeTip)
                 {
                     li.Attributes["title"] = item.Description;
                 }
                 _ltControl.Items.Add(li);
             }
         }
     }
 }
开发者ID:huyihuan,项目名称:BlueSky,代码行数:30,代码来源:SystemRole.cs


示例11: GetSelectedGuid

		public static Guid? GetSelectedGuid(ListControl ddl) {
			Guid? gVal = null;
			if (ddl.SelectedItem != null) {
				gVal = new Guid(ddl.SelectedValue);
			}
			return gVal;
		}
开发者ID:tridipkolkata,项目名称:CarrotCakeCMS,代码行数:7,代码来源:GeneralUtilities.cs


示例12: GetValue

 protected override object GetValue(ListControl ddl)
 {
     if (!string.IsNullOrEmpty(ddl.SelectedValue))
         return GetEnumValue(int.Parse(ddl.SelectedValue));
     else
         return null;
 }
开发者ID:spmason,项目名称:n2cms,代码行数:7,代码来源:EditableEnumAttribute.cs


示例13: BindList

 public static void BindList(ListControl _ltControl, bool _bIncludeSel, bool _bIncludeAll)
 {
     if (null != _ltControl)
     {
         _ltControl.Items.Clear();
         if (_bIncludeAll)
         {
             _ltControl.Items.Add(new ListItem("--全部--", ""));
         }
         if (_bIncludeSel)
         {
             _ltControl.Items.Add(new ListItem("--请选择--", ""));
         }
         SystemOrganization[] alist = SystemOrganization.List();
         if (alist != null && alist.Length != 0)
         {
             SystemOrganization[] array = alist;
             for (int i = 0; i < array.Length; i++)
             {
                 SystemOrganization item = array[i];
                 ListItem li = new ListItem(item.Name, string.Concat(item.Id));
                 _ltControl.Items.Add(li);
             }
         }
     }
 }
开发者ID:huyihuan,项目名称:BlueSky,代码行数:26,代码来源:SystemOrganization.cs


示例14: AddListItems

        public static void AddListItems(ListControl control, string keys, string values, string selectedValues)
        {
            if (control == null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(keys))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(values))
            {
                return;
            }

            var key = keys.Split(',');
            var value = values.Split(',');

            if (key.Count() != value.Count())
            {
                throw new InvalidOperationException("Key or value count mismatch. Cannot add items to " + control.ID);
            }

            for (var i = 0; i < key.Length; i++)
            {
                var item = new ListItem(key[i].Trim(), value[i].Trim());
                control.Items.Add(item);
            }

            foreach (ListItem item in control.Items)
            {
                //Checkbox list allows multiple selection.
                if (control is CheckBoxList)
                {
                    if (!string.IsNullOrWhiteSpace(selectedValues))
                    {
                        foreach (var selectedValue in selectedValues.Split(','))
                        {
                            if (item.Value.Trim().Equals(selectedValue.Trim()))
                            {
                                item.Selected = true;
                            }
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(selectedValues))
                    {
                        if (item.Value.Trim().Equals(selectedValues.Split(',').Last().Trim()))
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                }
            }
        }
开发者ID:Blacksmither,项目名称:mixerp,代码行数:60,代码来源:Helper.cs


示例15: Bind2RadioButtonList

 // This function binds the given RadioButtonList with the given data table with respect to the data text field and the value field.
 public static void Bind2RadioButtonList(ListControl rbl, DataTable dt, string textField, string valueField)
 {
     rbl.DataSource = dt;
     rbl.DataTextField = textField;
     rbl.DataValueField = valueField;
     rbl.DataBind();
 }
开发者ID:recepSungurtas,项目名称:increment-the-app,代码行数:8,代码来源:UI.cs


示例16: Bind2CheckBoxList

 // This function binds the given CheckBoxList with the given data table with respect to the data text field and the value field.
 public static void Bind2CheckBoxList(ListControl chk, DataTable dt, string textField, string valueField)
 {
     chk.DataSource = dt;
     chk.DataTextField = textField;
     chk.DataValueField = valueField;
     chk.DataBind();
 }
开发者ID:recepSungurtas,项目名称:increment-the-app,代码行数:8,代码来源:UI.cs


示例17: GetSelectedValue

		public static string GetSelectedValue(ListControl ddl) {
			string sVal = null;
			if (ddl.SelectedItem != null) {
				sVal = ddl.SelectedValue;
			}
			return sVal;
		}
开发者ID:tridipkolkata,项目名称:CarrotCakeCMS,代码行数:7,代码来源:GeneralUtilities.cs


示例18: McmsWebQuestion

 public McmsWebQuestion(string strId, bool bRequired, string strRequiredText, string strQuestion, string strControlBase, RepeatDirection rdLayout, string[] strResponses)
     : base(strId, "mcms", bRequired, strRequiredText, strQuestion)
 {
     this.m_listBox = new ListBox();
     this.m_checkBoxList = new CheckBoxList();
     this.m_listControl = null;
     if (strControlBase == "checkbox")
     {
         this.m_checkBoxList.RepeatDirection = rdLayout;
         this.m_listControl = this.m_checkBoxList;
     }
     else
     {
         this.m_listBox.SelectionMode = ListSelectionMode.Multiple;
         this.m_listControl = this.m_listBox;
     }
     foreach (string text in strResponses)
     {
         this.m_listControl.Items.Add(new ListItem(text));
     }
     this.m_listControl.ID = "lst_" + strId;
     this.Controls.Add(this.m_listControl);
     if (bRequired)
     {
         ListControlValidator child = new ListControlValidator();
         child.EnableClientScript = false;
         child.Text = strRequiredText;
         child.Display = ValidatorDisplay.Dynamic;
         child.ControlToValidate = this.m_listControl.ID;
         this.Controls.Add(child);
     }
     this.Controls.Add(new LiteralControl("</p>"));
 }
开发者ID:italiazhuang,项目名称:wx_ptest,代码行数:33,代码来源:McmsWebQuestion.cs


示例19: BindListControl

        private static Dictionary<string, Dictionary<int, string>> _EnumList = new Dictionary<string, Dictionary<int, string>>(); //枚举缓存池

        #endregion Fields

        #region Methods

        /// <summary>
        /// bind source for ListControl;ex:DropDown,ListBox;
        /// </summary>
        /// <param name="listControl"></param>
        /// <param name="enumType"></param>
        public static void BindListControl(ListControl listControl, Type enumType)
        {
            listControl.Items.Clear();
            listControl.DataSource = EnumToDictionary(enumType);
            listControl.DataValueField = "key";
            listControl.DataTextField = "value";
            listControl.DataBind();
        }
开发者ID:NameIsBad,项目名称:WXFlow,代码行数:19,代码来源:EnumHelper.cs


示例20: BindObject

 public static void BindObject(ListControl ddl, DataTable data, string textColumn, string valueConlumn, string defaultText)
 {
     ddl.DataSource = data;
     ddl.DataTextField = textColumn;
     ddl.DataValueField = valueConlumn;
     ddl.DataBind();
     ddl.Items.Insert(0, new ListItem(defaultText, "-1"));
 }
开发者ID:jpesquibel,项目名称:Projects,代码行数:8,代码来源:FormGeneratorTools.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WebControls.ListItem类代码示例发布时间:2022-05-26
下一篇:
C# WebControls.ListBox类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap