locked
Search for an Item in the DropdownList and then remove it RRS feed

  • Question

  • The following code popuplates a dropdownlist; how do I search for an item in the dropdown and remove it fi found?

    SPListItemCollection prodItems = list.Items; var prods = from SPListItem item in prodItems where Enum.GetName(typeof(WorkgroupEnum), this.Workgroup) == string.Empty || Convert.ToString(item["Workgroup"]) == Enum.GetName(typeof(WorkgroupEnum), this.Workgroup) orderby Convert.ToString(item["Desc"]) select Convert.ToString(item["Desc"]); _prodList.DataSource = prods; _prodList.DataBind();


    Wednesday, July 25, 2012 12:16 AM

Answers

  • Hi,

     
    ListItem itemToRemove = myDropDown.Items.FindByValue("value");
     if (itemToRemove != null) {     myDropDown.Items.Remove(itemToRemove); } 

    Wednesday, July 25, 2012 3:30 AM