I have a dropdownlist, and in some cases need to remove an item (in the code-behind). I need to remove the item based on the value of the item.
How can I do this?
Items. FindByValue("TextToFind"); drpCategory. Items. Remove(removeItem);
The DropDownList control is a web server element that creates the drop-down menu and lets users select a single item from various options. You can add any number of items to the DropDownList. Almost all web pages contain a drop-down list, but it is mostly present in registration forms or sign-in pages.
You can use this:
myDropDown.Items.Remove(myDropDown.Items.FindByValue("TextToFind"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With