ListItem itm=dropdownlist2.Items.FindByValue(firstdropdownlistValue); if(itm!=null) { dropdownlist2.Items.Remove(itm); }
int count = DropDownList.Items.Count - 1; for (int i = count; i > 0; i--) DropDownList.Items.RemoveAt(i);
ListItem itemToRemove = myDropDown.Items.FindByValue("value"); if (itemToRemove != null) { myDropDown.Items.Remove(itemToRemove); } Or if you know the index of the item to remove, use RemoveAt method : myDropDown.Items.RemoveAt(0);
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList1.SelectedItem.ToString() == "One") { DropDownList2.Items.Remove("One"); } else { DropDownList2.Items.Add("One"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)