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?
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?
You can use this:
I have Done Like this, i have remove all items except the value coming as 1 and 3.
There is also a slightly simpler way of removing the value.
values
As other people have answered, you need to do;
but if you want the page to refresh asynchronously, the dropdown needs to be inside an
asp:UpdatePanel
after you do the
Remove
call, you need to call:Code:
Replace "TextToFind" with the item you want to remove.