Click here to Skip to main content
11,925,851 members (62,647 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked

Load all the Country Names of the World in DropDown

, 29 Mar 2011 CPOL
Rate this:
Please Sign up or sign in to vote.


This shows how to bind Country names in DropDownList & also it contains some advantages.


<html xmlns="">
<head   runat="server">
    <title>Bind Country names in Dropdownlist</title>
    <form id="form1"   runat="server">
        <asp:DropDownList ID="ddlLocation" runat="server">        
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Collections;
using System.Text;
public partial class _Default : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e)
        ddlLocation.DataSource = CountryList();
        ddlLocation.DataTextField = "Key";
        ddlLocation.DataValueField = "Value";
    public SortedList CountryList()
        SortedList slCountry = new SortedList();
        string Key = "";
        string Value = "";
        foreach (CultureInfo info in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
            RegionInfo info2 = new RegionInfo(info.LCID);
            if (!slCountry.Contains(info2.EnglishName))
                Value = info2.TwoLetterISORegionName;
                Key = info2.EnglishName;
                slCountry.Add(Key, Value);
        return slCountry;


  • Here, Country names are loading from code behind so we can apply some filter/restriction for the items list here.(Example: Loading European countries, Loading Country names starts with 'A', etc.,)
  • Here TwoLetterISORegionName is used to DataValueField for DropDownList but we can use other things such as ThreeLetterISORegionName, NativeName, ISOCurrencySymbol, GeoId, CurrencySymbol, etc., from RegionInfo class
  • We can sort the Key field because SortedList was used here


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
India India
Coming soon....

You may also be interested in...

Comments and Discussions

GeneralReason for my vote of 5 best solution so far Pin
janwel26-May-11 22:12
groupjanwel26-May-11 22:12 
GeneralReason for my vote of 5 good Pin
CS201130-Mar-11 6:32
memberCS201130-Mar-11 6:32 
GeneralReason for my vote of 5 This probably would be the best solu... Pin
DrABELL29-Mar-11 10:05
memberDrABELL29-Mar-11 10:05 
GeneralRe: Yes it was me who reported that, a few countries were missin... Pin
Tarun.K.S1-Apr-11 8:50
memberTarun.K.S1-Apr-11 8:50 
Yes it was me who reported that, a few countries were missing in the list and few were repeated many times in the list. Second alternative fixes this issue.
GeneralBut not all countries are getting displayed. Pin
Tarun.K.S29-Mar-11 5:03
memberTarun.K.S29-Mar-11 5:03 
GeneralRe: I just noticed that...I'll update the code Tarun. Thanks. Pin
thatraja29-Mar-11 18:53
mvpthatraja29-Mar-11 18:53 
GeneralRe: But not all countries are getting displayed. Pin
Member 966201013-Dec-12 0:55
memberMember 966201013-Dec-12 0:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151126.1 | Last Updated 29 Mar 2011
Article Copyright 2011 by thatraja
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid