I have a dropdown : myDropDown.
And I need to remove all ListItem in its item collection which does not have a value equals to ‘-1’ ?
myDropDown.Items. ... // TODO: Remove all ListItems that has a value different than '-1'
I don’t want to create a loop etc.
How can I achieve this in a most self-documenting way? I assume with a LINQ statement.
Thanks
Assuming you are working with a
System.Web.UI.WebControls.DropDownList, I think the good oldforloop is the best choice here: