Reputation: 372
I have a drop down list which is filled via a DataGrid. In certain cases I would like to remove some items from this list. The variable "SoftwareToRemoveFromList" will be filled with the item I want to remove.
So far I have this code:
Dim removeListItem As ListItem = SoftwareDropDown.Items.FindByText(SoftwareToRemoveFromList)
SoftwareDropDown.Items.Remove(removeListItem)
This runs without error and the contents of "removeListItem" has the string that I want to remove from the drop down. However, when it runs it doesn't actually remove anything from the drop down? Just wondering what I'm missing here?
Upvotes: 0
Views: 242
Reputation: 545
Removing by index works for me
Dim removeListItem As Integer = SoftwareDropDown.Items.IndexOf(SoftwareDropDown.Items.FindByText(SoftwareToRemoveFromList))
SoftwareDropDown.Items.RemoveAt(removeListItem)
Upvotes: 1