Last post Jan 21, 2019 12:55 PM by yogyogi
Jan 19, 2019 06:39 AM|fatihbarut|LINK
Please help me to solve the (simplified sample) scenario below .
we have 2 dropdowns (inputs with datalists). First is Countries Second is States when the first is selected the second is prepared by filtering for country.
My approach is below but dont know how to do it or not sure it is the best.
1- At page load download countries (using entity framework model) and make them datalist of countries input
2- At page load download states and append them in a kind of data list (json or something like that or as a model)
3- When the user keyup in the states input, I want to filter states with "Startwith" and "Selected Country"
and so on.
How can I do this or should I do this?
(I didn't want to solve this with entity framework to not overload the server in every key up event and wanted to solve it client side)
Jan 21, 2019 06:35 AM|Nan Yu|LINK
Hi fathbarut ,
the states dropdownlist based on the section of country :
Jan 21, 2019 12:55 PM|yogyogi|LINK
This is the concept of Cascading drop down controls. In your states dropdown change event you call jQuery that will fill the city dropdown based on the selected states in the states dropdown.
Kindly check this reference tutorial - How to Populate Cascading Dropdownlist with AJAX in ASP.NET
If you want to filter out all the cities based on states ddl selected value, then you have to keep all the cities with there states in json format in some hidden text box. Then you filter the cities values from the json and bind the city ddl with it.