Friday, May 2, 2008

Removing items from dropdownlist.

The following will remove nothing:

this.DropDownList1.Items.Remove("Manchester"); //Text

this.DropDownList1.Items.Remove("201"); //Value

Remove() works by first constructing a new ListItem from the specified string, and then removing the specified ListItem. In other words, Remove item works as below:

this.DropDownList1.Items.Remove(new ListItem("Manchester"));

No comments: