Hey buddy, I need help in Visual Studio 2008. I want to linked 3 dropdown lists in ASP.NET & C#. also want to know search function. If somebody online then plz let me know.
You will have to be more specific.. What you mean to link three list box?? is that for the validation controls? If so, look up the Group Validation attribute.. Isaac, http://www.7Live7.com
It have to link three dropdown lists (Countries, States and Cities) in the way If i select US in next dropdown list its show only US states same with Cities.. Thanks for reply
You have to store information about cities/stats in a database, to identify which country they belong to. After that make all DropDowns' ActivePostBack to True, create OnCahge event, and connect to the database to change available cities/states.
Hi shaz_again asmaster has the right idea. Basically what you want to do is have 3 datatables for Countries, States and Cities in an SQL datatbase or even just an XML datatable. Then you want to populate the drop down list using all the rows from the Countries datatable. When the user selects a country, you want to set the OnChange event to trigger another datatable query. This time you want it to select all states for a specific country. Here is an example Basic data table layout Table Name: States stateID | Country | State 0 | United States | Texas 1 | United States | New York 2 | Canada | State.. 3 | Singapore | State.. and so on ..... Then you can just use a LINQ to SQL query to get a list of States where the country is equal to the selected country, like so: //Lets say the user chose United States string strCountry = "United States"; //Get all states where country is equal to the selected country List<State> lstStates = db.States.Where(s=> s.Country == strCountry).ToList<State>(); Then just populate the States drop down using the lstStates List. If you want this so happen without the page refreshing, make an ajax request using something like jquery to get the List from a page on your site that returns JSON or XML. (I would suggest JSON) http://www.json.org/ Also, if you are using MVC just have an ActionResult return a JavaScript object made using the JSONSerializer class. Hope this helps aspdev