开发者

Creating a dynamic dropdown, after a selection has been made

开发者 https://www.devze.com 2023-04-10 23:04 出处:网络
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, Nis

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)

开发者_如何学JAVA

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.


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


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


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;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号