Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net: How can I remove an item from a dropdownlist?

Tags:

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?

like image 785
chris Avatar asked Mar 07 '11 16:03

chris


People also ask

How do I remove a specific item from a DropDownList in asp net?

Items. FindByValue("TextToFind"); drpCategory. Items. Remove(removeItem);

What is DropDownList asp net?

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.


1 Answers

You can use this:

myDropDown.Items.Remove(myDropDown.Items.FindByValue("TextToFind")); 
like image 58
Gonza Oviedo Avatar answered Sep 21 '22 09:09

Gonza Oviedo