0

I have a couple CascadingDropDown Lists, which are working properly. What I can't figure out is how to pre-populate the dropdownlists until a parent selection is made.

Here's an example:

Let's say I have two CascadingDropDowns: 1) Country 2) State

When a user selects a country, the state dropdownlist is enabled and populated using the CascadingDropDown webservice. In this scenario, a user must select a Country to select State. Until a Country is selected, the state cascadingdropdown is disabled (I tried the EnableAtLoading but it failed to load any values in State). I want to populate the State DropDown with every state in the database until a Country is selected. At that time, the State list is set to those states associated with the selected country. I hope this makes sense.

Assume that the query to populate the state ddl with every state is

SELECT DISTINCT state FROM location

So, what I want to do is: Populate the state dropdownlist with every state until a country is selected. At that time, the state ddl is reset to only those associated with the selected country in the parent allowing the CascadingDropDown extender to override the dropdownlist data binding (the standard procedure with ccds)

How is this done?

paradoja
  • 3,055
  • 2
  • 25
  • 34

2 Answers2

0

Jquery is a better option for doing this. Check the below question to understand how to do it:

How to populate a cascading Dropdown with JQuery

Community
  • 1
  • 1
Adarsh Shah
  • 6,755
  • 2
  • 25
  • 39
0

You are right Adarsh. I abandoned the ajaxtoolkit cascadingdropdowns and went with jQuery instead. Using the latter, dropdownlists are initially populated using SqlDataSources. Parent selections are cascaded to child dropdownlists using jQuery change events. A great tutorial to get anyone started can be found at http://www.aspdotnet-suresh.com/2013/10/jquery-cascading-dropdown-list-in-aspnet.html.