FluxEngine
FluxEngine

Reputation: 13310

Creating a dynamic dropdown, after a selection has been made

I am trying to create a dynamic dropdown after a dropdown has been selested (in asp.net vb)

For example: I have a dropdown question that asks: What brand of car do you drive (Toyota, Ford, Honda, Nissan, Chevrolet)

When the brand is selected I want another dropdown to appear under it with new chocies

For example: If Nissan is chosen, the second dropdown will be populated (from the database) with (Altima, Maxima, etc...)

And in some cases I would like a text box to appear, but If I can figure out the dropdown portion, I am sure I can figure out the textbox.

Thanks in advance.

Upvotes: 0

Views: 1123

Answers (3)

Tim Schmelter
Tim Schmelter

Reputation: 460380

As suggested in the comments, i'm putting this in as an answer

If you are using Ajax, you could use the AjaxControlToolkit's CascadingDropdownExtender.

Here is the direct link to it: http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx

And here is a Video-Tutorial: http://www.asp.net/ajax/videos/how-do-i-use-the-aspnet-ajax-cascadingdropdown-control-extender

Upvotes: 1

sh_kamalh
sh_kamalh

Reputation: 3901

In the DropDownList selected index changed event, you can do whatever you want. You can show the other DropDownList or the other TextBox and you can also bind the DropDownList with the items you want.

Your code could look like:

ddlModel.DataSource = GetModels(ddlCar.SelectedValue);
ddlModel.Visible = true;

Upvotes: 0

Simon Halsey
Simon Halsey

Reputation: 5477

Like this?

http://www.codeproject.com/KB/custom-controls/ajaxdropdownlist.aspx

There are quite a few examples if you look on Google.

http://www.google.com/search?q=ajax%20dropdownlist

Upvotes: 0

Related Questions