How to get list of all countries and bind to a dropdown list in ASP.NET
Create an ASP.NET application and add a DropDownList to the page something like this.
- <asp:DropDownList ID="ddlCountry" runat="server"></asp:DropDownList>
Now call this GetCountryList method on your page load that will bind and display countries in the DropDownList.
- public List<string> GetCountryList()
- {
- List<string> list = new List<string>();
- CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures |
- CultureTypes.SpecificCultures);
- foreach (CultureInfo info in cultures)
- {
- RegionInfo info2 = new RegionInfo(info.LCID);
- if (!list.Contains(info2.EnglishName))
- {
- list.Add(info2.EnglishName);
- }
- }
- return list;
- }
- ddlLocation.DataSource = GetCountryList();
- ddlLocation.DataBind();
- ddlLocation.Items.Insert(0, "Select");
Note: Updated attachement contains code for orderby the list using LINQ.

Raj KumareditedPosted Sep 21, 2010, 6:14 AMEdited Sep 24, 2010, 1:54 AM
using System.Globalization; using System.Collections.Generic; public List<string> GetCountryList() { List<string> list = new List<string>(); // CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures | CultureTypes.SpecificCultures); foreach (CultureInfo info in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { RegionInfo info2 = new RegionInfo(info.LCID); if (!list.Contains(info2.EnglishName)) { list.Add(info2.EnglishName); list.Sort(); } } return list; } ddlCountry.DataSource = GetCountryList(); ddlCountry.DataBind(); ddlCountry.Items.Insert(0, "Select");
MacPosted Sep 1, 2010, 5:22 AM
Nice Article, Interesting One.. thank you..
Nusmir AlicPosted Aug 26, 2010, 8:56 AM
if (!list.Contains(info2.EnglishName))<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p> {<o:p></o:p> list.Add(info2.EnglishName);<o:p></o:p> //bether look list.Sort(); }<o:p></o:p>
Purushottam RathorePosted Aug 25, 2010, 5:52 AM
Hi suthish This is good article but its not running, I have got an error at this line RegionInfo info2 = new RegionInfo(info.LCID);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p> Error is: There is no region associated with the Invariant Culture (Culture ID: 0x7F). Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: There is no region associated with the Invariant Culture (Culture ID: 0x7F). Source Error: Line 29: foreach (CultureInfo info in cultures) Line 30: { Line 31: RegionInfo info2 = new RegionInfo(info.LCID); Line 32: if (!list.Contains(info2.EnglishName)) Line 33: {
Satyapriya NayakPosted Aug 24, 2010, 3:01 PM
Dear sir, Its showing some errors Error 1 The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?