list of countries and States

Rani

Well-known member
Joined
Nov 19, 2005
Messages
71
Programming Experience
Beginner
[SIZE=-1]I would like to populate ASP.NET Dropdown list with a list of countries. and a DropDown List with a list of States.[/SIZE]
I do not know how to do that. First of all i do not have list to populate where and how would i get that?
Thanks
 
You break out an atlas or you use some other Web site or some field in some other software that includes a country list. Use a little imagination. How many Web sites have you registered for that ask you to select a country from a list? Outlook has a country list when creating a new contact, as would many other e-mail clients I'd imagine.
 
okay when i have the list what am i supposed to do. can you get me a head start? I am new and i do not know. thanks
 
Thanks. Now i have the list.
how would i use this in my registration page to populate in my dropdown list?
Thanks
 
This is more of an asp.net question.

if your countries are listed in a table called tblCountries, with 2 columns: ID and CountryName
and your States are in another table called tblStates with 3 columns: ID, CountryID and State

Your first dropdownlist's Data source should just be "Select * from tblCountries order by CountryName"

Your second DDL's Data source should be "Select * from tblStates where countryID=@CountryID order by State"

By putting @CountryID in there, we have created a Parameter.

When you enter this Select statement in your datasource, (provided you are using the data source wizard) it will then ask you for the source of the parameter - in this case, you will select that you want the value to come from a control, and then select the first drop down list.

Then, make sure that the first drop down list is set to auto post back, and you are there.
 
Back
Top