Pages

Dec 23, 2008

How to Remove item from DropDownList by Value

// 1st method, to Remove item from DropDownList by Value
ListItem li = dropdownlist.Items.FindByValue(strValue);
if(li != null)
dropdownlist.Items.Remove(li);
// 2nd method, combined form
dropdownlist.Items.RemoveAt(
dropdownlist.Items.IndexOf(dropdownlist.Items.FindByValue(strValue))
);

No comments: