當前位置: 首頁>>代碼示例>>C#>>正文


C# WebControls.ListControl類代碼示例

本文整理匯總了C#中System.Web.UI.WebControls.ListControl的典型用法代碼示例。如果您正苦於以下問題:C# ListControl類的具體用法?C# ListControl怎麽用?C# ListControl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ListControl類屬於System.Web.UI.WebControls命名空間,在下文中一共展示了ListControl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的System.Web.UI.WebControls.ListControl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。