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


C# ListItemCollection.Clear方法代码示例

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


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

示例1: BindListItem

 public static void BindListItem(ListItemCollection LIC, DataView DataSource, string TextField, string ValueField)
 {
     LIC.Clear();
     for (int i = 0; i < DataSource.Count; i++)
     {
         LIC.Add(new ListItem(DataSource[i][TextField].ToString(), DataSource[i][ValueField].ToString()));
     }
 }
开发者ID:kingofhawks,项目名称:kcsj,代码行数:8,代码来源:CommonFunc.cs

示例2: FillTreeData

 public static void FillTreeData(ListItemCollection lst, DataTable dtCommands, string fieldKey, string fieldName, string fieldParentID, string sortBy)
 {
     lst.Clear();
     DataRow[] drRoots = dtCommands.Select(fieldParentID + "  = " + 0, sortBy);
     foreach (DataRow row in drRoots)
     {
         ListItem item = new ListItem();
         item.Value = row[fieldKey].ToString();
         item.Text = row[fieldName].ToString();
         item.Attributes.Add("Level", "0");
         lst.Add(item);
         LoadCmdItem(lst, item, dtCommands, fieldKey, fieldName, fieldParentID, sortBy);
     }
 }
开发者ID:haoas,项目名称:CRMTPE,代码行数:14,代码来源:MiscUtility.cs

示例3: BindMetaTypesItemCollections

        public static void BindMetaTypesItemCollections(ListItemCollection items, bool IsAllItems)
        {
            ResourceManager LocRM2 = new ResourceManager("Mediachase.Ibn.WebResources.App_GlobalResources.Admin.Resources.strDefault", Assembly.Load(new AssemblyName("Mediachase.Ibn.WebResources")));
            ResourceManager LocRM = new ResourceManager("Mediachase.UI.Web.App_GlobalResources.Lists.Resources.strLists", typeof(CommonHelper).Assembly);
            items.Clear();
            if (IsAllItems)
                items.Add(new ListItem(LocRM2.GetString("tAllTypes"), "-1"));
            MetaTypeCollection coll = MetaType.GetMetaDataMetaTypes();
            Hashtable htTypes = new Hashtable();
            htTypes.Clear();
            foreach (MetaType type in coll)
            {
                if (!(type.MetaDataType == MetaDataType.DictionaryMultivalue
                    || type.MetaDataType == MetaDataType.DictionarySingleValue
                    || type.MetaDataType == MetaDataType.EnumMultivalue
                    || type.MetaDataType == MetaDataType.EnumSingleValue
                    || type.MetaDataType == MetaDataType.StringDictionary
                    || type.MetaDataType == MetaDataType.MetaObject))
                    htTypes.Add(type.Id.ToString(), type.FriendlyName);
            }
            items.Add(new ListItem(htTypes["31"].ToString(), "31"));
            htTypes.Remove("31");
            items.Add(new ListItem(htTypes["32"].ToString(), "32"));
            htTypes.Remove("32");
            items.Add(new ListItem(htTypes["26"].ToString(), "26"));
            htTypes.Remove("26");
            items.Add(new ListItem(MetaType.Load(MetaDataType.Money).FriendlyName, "9"));
            items.Add(new ListItem(MetaType.Load(MetaDataType.Float).FriendlyName, "6"));
            items.Add(new ListItem(htTypes["28"].ToString(), "28"));
            htTypes.Remove("28");
            items.Add(new ListItem(MetaType.Load(MetaDataType.DateTime).FriendlyName, "4"));

            items.Add(new ListItem(LocRM.GetString("Dictionary"), "0"));

            items.Add(new ListItem(htTypes["27"].ToString(), "27"));
            htTypes.Remove("27");
            items.Add(new ListItem(htTypes["30"].ToString(), "30"));
            htTypes.Remove("30");
            items.Add(new ListItem(htTypes["33"].ToString(), "33"));
            htTypes.Remove("33");
            items.Add(new ListItem(htTypes["29"].ToString(), "29"));
            htTypes.Remove("29");
            items.Add(new ListItem(htTypes["39"].ToString(), "39"));
            htTypes.Remove("39");
            items.Add(new ListItem(htTypes["40"].ToString(), "40"));
            htTypes.Remove("40");

            foreach (string s in htTypes.Keys)
                items.Add(new ListItem(htTypes[s].ToString(), s));
        }
开发者ID:0anion0,项目名称:IBN,代码行数:50,代码来源:CommonHelper.cs

示例4: InitListItems

 /// <summary>
 /// 绑定控件的ListItem项
 /// </summary>
 /// <param name="LIC"></param>
 /// <param name="IsFistNull"></param>
 public void InitListItems(ListItemCollection LIC, bool IsFistNull)
 {
     if (LIC.Count > 0)
     {
         LIC.Clear();
     }
     Hashtable ht = GetTextValue();
     foreach (DictionaryEntry de in ht)
     {
         LIC.Add(new ListItem(de.Value.ToString(), de.Key.ToString()));
     }
     if (IsFistNull)
     {
         LIC.Insert(0, "");
     }
 }
开发者ID:kingofhawks,项目名称:kcsj,代码行数:21,代码来源:CommonEnum.cs

示例5: DataBindTeacherTypeList

 public void DataBindTeacherTypeList(ListItemCollection itemCollection, string teacherType)
 {
     itemCollection.Clear();
     ListItem[] listItems = new ListItem[]
     {
       new ListItem("所有教师", "0"),
       new ListItem("院内教师/助教", "1"),
       new ListItem("院外教师", "2"),
       new ListItem("院外助教", "3")
     };
     if(teacherType != null && teacherType.Trim().Length != 0)
     foreach(ListItem listItem in listItems)
     {
         if(listItem.Value == teacherType.Trim())
         {
             listItem.Selected = true;
             break;
         }
     }
     itemCollection.AddRange(listItems);
 }
开发者ID:skyaspnet,项目名称:usta,代码行数:21,代码来源:SalaryManage.aspx.cs

示例6: Methods

		public void Methods ()
		{
			ListItemCollection	c;
			ListItem		i;
			ListItem		i2;

			c = new ListItemCollection();
			Assert.AreEqual (0, c.Count, "T1");

			i = new ListItem("Item 1", "10");
			c.Add(i);
			Assert.AreEqual (1, c.Count, "T2");

			i = new ListItem("This is item 2", "20");
			c.Add(i);
			Assert.AreEqual (2, c.Count, "T3");

			Assert.AreEqual (null, c.FindByText(" is "), "T4");
			Assert.AreEqual (i.Text, c.FindByText("This is item 2").Text, "T5");
			Assert.AreSame (i, c.FindByText("This is item 2"), "T6");
			Assert.AreEqual (1, c.IndexOf(c.FindByText("This is item 2")), "T7");
			Assert.AreEqual (1, c.IndexOf(c.FindByValue("20")), "T8");

			i = new ListItem("Item 3", "30");
			Assert.IsFalse(c.Contains(i), "T9");
			c.Add(i);
			Assert.IsTrue(c.Contains(i), "T10");

			i = new ListItem("Forth", "40");
			i2 = new ListItem("Fifth", "50");
			c.AddRange(new ListItem[] {i, i2});
			Assert.AreEqual (5, c.Count, "T11");

			c.RemoveAt(1);
			Assert.AreEqual (4, c.Count, "T12");
			Assert.AreEqual (null, c.FindByText("This is item 2"), "T13");

			c.Clear();
			Assert.AreEqual (0, c.Count, "T13");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:40,代码来源:ListItemCollectionTest.cs

示例7: DataBindSearchTermTagList

 //绑定学期标识下拉列表
 public void DataBindSearchTermTagList(ListItemCollection itemCollection, string termValue)
 {
     itemCollection.Clear();
     DalOperationAboutCourses doac = new DalOperationAboutCourses();
     DataTable dt = doac.FindAllTermTags().Tables[0];
     string termTag = null;
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         termTag = dt.Rows[i]["termTag"].ToString().Trim();
         ListItem li = new ListItem(CommonUtility.ChangeTermToString(termTag), termTag);
         if (termValue == li.Value)
         {
             li.Selected = true;
         }
         itemCollection.Add(li);
     }
     ListItem itemAll = new ListItem("全部学期", "all");
     if ("all" == termValue) {
         itemAll.Selected = true;
     }
     itemCollection.Add(itemAll);
 }
开发者ID:skyaspnet,项目名称:usta,代码行数:23,代码来源:SalaryView.aspx.cs

示例8: LoadListItems

        /// <summary>
        /// Loads the list items.
        /// </summary>
        /// <param name="listCollection">The list.</param>
        /// <param name="dataReader">The data reader.</param>
        /// <param name="textField">The text field.</param>
        /// <param name="valueField">The value field.</param>
        /// <param name="selectedValue">The selected value.</param>
        /// <param name="closeReader">if set to <c>true</c> [close reader].</param>
        public static void LoadListItems(ListItemCollection listCollection, IDataReader dataReader, string textField, string valueField, string selectedValue, bool closeReader)
        {
            listCollection.Clear();

            if (closeReader)
            {
                using (dataReader)
                {
                    while (dataReader.Read())
                    {
                        string sText = dataReader[textField].ToString();
                        string sVal = dataReader[valueField].ToString();

                        ListItem l = new ListItem(sText, sVal);
                        if (!String.IsNullOrEmpty(selectedValue))
                            l.Selected = selectedValue.Matches(sVal);
                        listCollection.Add(l);
                    }
                    dataReader.Close();
                }
            }
            else
            {
                while (dataReader.Read())
                {
                    string sText = dataReader[textField].ToString();
                    string sVal = dataReader[valueField].ToString();

                    ListItem l = new ListItem(sText, sVal);
                    if (!String.IsNullOrEmpty(selectedValue))
                        l.Selected = selectedValue.Matches(sVal);
                    listCollection.Add(l);
                }
            }
        }
开发者ID:lengocluyen,项目名称:pescode,代码行数:44,代码来源:Utility.cs

示例9: BuscaUsuario

        protected void BuscaUsuario()
        {
            try
            {
                IUsuarios negocio = new BusinessLogic();
                USUARIO userSesion = Session["userToModify"] as USUARIO;
                USUARIO usuario = negocio.BuscaUsuarioRol(userSesion.NOMBRECOMPLETO);
                lblNombreUsuario.Text = userSesion.NOMBRECOMPLETO;
                List<ROL> roles = Session["Roles"] as List<ROL>;
                ListItemCollection collection = new ListItemCollection();
                ListItem item = null;
                if (usuario == null)
                {
                    collection.Clear();

                    foreach (ListItem valor in rblPerfiles.Items)
                    {
                        item = new ListItem { Text=valor.Text,Value=valor.Value};
                        collection.Add(item);
                    }
                    rblPerfiles.Items.Clear();
                    foreach (ListItem valor in collection)
                        rblPerfiles.Items.Add(valor);
                    throw new Exception("Usuario no encontrado");
                }
                Session.Add("UsuarioBuscado", usuario);
                collection.Clear();
                usuario.ROLUSUARIO.ToList().OrderBy(rol => rol.IDROL).ToList().ForEach(rolSelected =>
                {
                    roles.OrderBy(rol => rol.IDROL).ToList().ForEach(rol =>
                    {
                        if (rol.IDROL == rolSelected.IDROL)
                        {
                            item = new ListItem
                            {
                                Text = rol.DESCRIPCIONROL,
                                Value = rol.IDROL.ToString(),
                                Selected = true
                            };
                        }
                        else
                        {
                            item = new ListItem
                            {
                                Text = rol.DESCRIPCIONROL,
                                Value = rol.IDROL.ToString()
                            };
                        }
                        if(!collection.Contains(item))
                            collection.Add(item);
                    });
                });
                if (collection.Count > 0)
                {
                    rblPerfiles.Items.Clear();
                    foreach (ListItem valor in collection)
                        rblPerfiles.Items.Add(valor);
                }
            }
            catch (Exception ex)
            {
                MostrarError(ex.Message);
            }
        }
开发者ID:ramirobr,项目名称:DQBase,代码行数:64,代码来源:AsignarPerfilUsuario.aspx.cs

示例10: buildListBox

 public void buildListBox(ListItemCollection Items,string[] values, string CustomInitialDisplayValue,string CustomInitialSubmitValue)
 {
     Items.Clear();
     if(CustomInitialDisplayValue!=null) Items.Add(new ListItem(CustomInitialDisplayValue,CustomInitialSubmitValue));
     for(int i=0;i<values.Length;i+=2)Items.Add(new ListItem(values[i+1],values[i]));
 }
开发者ID:dudug,项目名称:bookstore_before_Fix,代码行数:6,代码来源:CCUtility.cs

示例11: FillDatabaseVersions

        public void FillDatabaseVersions(int packageId, ListItemCollection items, List<string> versions)
        {
            if (versions == null)
                return;

            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            items.Clear();
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2000, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2005, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2008, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2012, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2014, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MySql4, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MySql5, items, versions);
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:17,代码来源:WebsitePanelControlBase.cs

示例12: BuildOptions

		protected void BuildOptions(ListItemCollection listItems, List<ChoiceOption> configuredOptions, List<string> values)
		{
			listItems.Clear();
            bool hasValues = values != null && values.Count != 0;
			List<string> valueList = hasValues ? new List<string>(values) : new List<string>();
			var extraItem = new ListItem(ExtraOptionText, ExtraOptionValue, true);

			foreach (ChoiceOption option in configuredOptions)
			{
				var newItem = new ListItem(option.Text, option.Value, option.Enabled);
				if (hasValues)
				{
					newItem.Selected = valueList.Contains(option.Value);
					valueList.Remove(option.Value);
				}
				else
				{
					newItem.Selected = option.Selected;
				}
				listItems.Add(newItem);
			}
			if (AllowExtraValue)
			{
				listItems.Add(extraItem);
			}
			if (hasValues && valueList.Count > 0)
			{
				extraItem.Selected = true;
				SetExtraValue(valueList[0]);
			}
		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:31,代码来源:ChoiceControl.cs

示例13: LoadListItems

        public static void LoadListItems(ListItemCollection list, IDataReader rdr, string textField, string valField, string selectedValue, bool closeReader)
        {
            list.Clear();

            while (rdr.Read())
            {
                string sText = rdr[textField].ToString();
                string sVal = rdr[valField].ToString();

                ListItem l;
                l = new ListItem(sText, sVal);
                if (!String.IsNullOrEmpty(selectedValue))
                {
                    if (IsMatch(selectedValue, sVal))
                    {
                        l.Selected = true;
                    }
                }
                list.Add(l);
            }
            if (closeReader)
                rdr.Close();
        }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:23,代码来源:Utility.cs


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