Friday, March 23, 2012

How to make a dropdownlist empty

I have a listbox that lists countries....and if you choose a country, another listbox show cities in that country (fetched from a sql database)....And if you then chose a city in the second listbox, a dropdownlist will show restaurants in the city....(also fetched from a sql-database)...

Ok...I hope you understand...now to the problem....:

If you first chose a country, a city and a restaurant but then want to chose another country in the first listbox, the dropdownlist for the restaurants is still there filled with restaurants for the first country...I dont know how to "remove" the restaurants so that the dropdownlist is blank if someone switch country....

I think I need to do something in countryListbox_SelectedIndexChange....but I dont know what to write there....

I know that I can make the dropdownlist invisible by entering the following code:

sub countryListbox_SelectedIndexChange

dropdownlistRestaurants.visible = false

End sub

But I want it to be visible all the time!

Do you know what I could do?

You'ew not in the right forum, but in your code you can add the following code to clear the ddl:

dropdownlistRestaurants.Items.Clear() in countryListbox_SelectedIndexChange event

No comments:

Post a Comment