Billy
Billy

Reputation: 15706

2nd dropdownlist changes based on the choice of 1st dropdownlist in ASP.NET

I want to change the 2nd dropdownlist based on the choice of 1st dropdownlist. The data is not too much in my case.

I don't want to trigger postback when choosing the 1st dropdownlist.

I'll use linq to sql to save the data into DB after submission.

What I think of is the following :

Get all the data in JSON format, and use javascript to load the 2nd dropdownlist. But in this case, we cannot ensure the value of 2nd ddl is correct (and turn the enableeventvalidation to false). I think it's less secure for sql injection, but using linq to sql, it should not be a problem.

What will you do? Is there any better way to do this?

Upvotes: 0

Views: 356

Answers (2)

Kevin LaBranche
Kevin LaBranche

Reputation: 21078

can / do you want to use the ajax toolkit? Has cascading dropdown just for this?

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/CascadingDropDown/CascadingDropDown.aspx

Upvotes: 1

Phaedrus
Phaedrus

Reputation: 8421

Have you considered a cascading drop down list? I'm not sure if it suits your needs exactly but it's worth checking out.

Cascading Drop Down

Upvotes: 1

Related Questions