Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing a drop down list in C#

I truly do hate to ask such a crayon-question... I'm trying to clear, not remove a drop down combo list in VSC#. My ddl lets the user choose the payRate of an employee. I've researched everywhere, even here, and everything suggests using..

   cmboPayRate.Items.Clear();   .. or
   cmboPayRate.SelectedIndex = - 1;

I even threw in

cmboPayRate.SelectedItem = -1;   

for safe measure. Nothing working. Again, I know this is easy(should be), but not working for me. Any suggestions would be greatly appreciated.

Thanks -Matt.

like image 914
Mateo eMayo Avatar asked Jul 08 '13 04:07

Mateo eMayo


People also ask

How to clear dropdown list in c#?

to clear a dropdownlist, you do DropDownList1. Items. Clear();

How to clear the dropdown list in vb?

ClearSelection() did exactly what I needed it to do. It cleared the dropdownlist selection so that nothing was selected. The box was blank, but when you dropdown the list, all the options are still available to choose from.

How to clear dropdown list in jquery?

Just use . empty() : // snip... }). done(function (data) { // Clear drop down list $(dropdown).


Video Answer


2 Answers

try

DropDownList1.Items.Clear(); 

No hidden and clear the Drop Down List.

like image 94
Segan Avatar answered Oct 12 '22 10:10

Segan


you can do as below

while(cmboPayRate.Items.Count>0)
   cmboPayRate.Items.RemoveAt(0);
like image 5
Damith Avatar answered Oct 12 '22 11:10

Damith