How to bind Dropdownlist from all countries name in c#

August 09, 2015 0 Comments

In this article i will show you how to bind the dropdownlist to countries name. You can say load dropdownlist from countries names like United State, United Kingdom etc in c#. By the System.Globalization namespace you can bind dropdownlist to countries name in c#.
In previous article i explained some topics on dropdownlist:

Source code of this article:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BindCountries.aspx.cs" Inherits="BindCountries" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:DropDownList ID="DropDownList1" runat="server" Height="28px" Width="118px"></asp:DropDownList>

Code Behind:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class BindCountries : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
            List<string> countries = new List<string>();
            CultureInfo[] culture = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
            foreach (CultureInfo item in culture)
                RegionInfo region = new RegionInfo(item.LCID);
            DropDownList1.DataSource = countries;

Above mentioned code define the following:
I have a list with string type, bind this English name of all countries name using System.Globalization namespace. First to bind array with the all cultures, now from all cultures you can get specific region.

Code generate the following output

How to bind Dropdownlist from all countries name in c#

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google