Click here to Skip to main content
11,571,471 members (75,767 online)
Click here to Skip to main content

Tagged as

Load all the Country Names of the World in DropDown

, 7 May 2011 CPOL 5.3K 2
Rate this:
Please Sign up or sign in to vote.
Step1.Downlo...
Step1.
Download coma separated .CSV country file.
Step2.
Create new table for country
suppose CountryId,Country are their fields.
USE TestData
GO
CREATE TABLE Tbl_COUNTRY
( 
CountryId VARCHAR(40),
Country VARCHAR(40)
)
GO
Step3.
Now run following script to load all the data from CSV to database table
BULK
INSERT Tbl_COUNTRY
FROM 'c:\country_data.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO

Step4.
protected void Page_Load(object sender, EventArgs e)
 {
        
        ddlLocation.DataSource = LoadCountryData() as DataTable;
        ddlLocation.DataTextField = "Country";
        ddlLocation.DataValueField = "CountryId";
        ddlLocation.DataBind();
 }

Download countrylist.csv
countrylist.txt[^]
coutrylist.csv[^]

License

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

Share

About the Author

ambarishtv
Software Developer
India India





Hi I' Ambarish from India. I've three and half year of experience in application
development solutions.

Educational Qualification

MCA -  from KristuJyoti College of management and technology (MG
University)

B.Sc (Physics) - from NSS College, Changanacherry (MG University)

Skill Set

C#,winforms,asp.net,MVC 3, Java,Design Patterns,VB, Android,JQuery Mobile,SQL,MySqlUML.


You may also be interested in...

Comments and Discussions

 
GeneralHi Anil. countrylist.csv file column has unsupported data fo... Pin
ambarishtv7-May-11 22:01
memberambarishtv7-May-11 22:01 
GeneralWhen I run the following BULK INSERT Tbl_COUNTRY FROM 'C:\\c... Pin
Anil Srivastava7-May-11 10:16
memberAnil Srivastava7-May-11 10:16 
GeneralThank You Pin
ambarishtv3-May-11 4:01
memberambarishtv3-May-11 4:01 
General5 for giving the link .. Now it became a complete solution. Pin
Prasanta_Prince3-May-11 4:00
memberPrasanta_Prince3-May-11 4:00 
GeneralReason for my vote of 5 Good solution after giving the CSV l... Pin
Prasanta_Prince3-May-11 3:59
memberPrasanta_Prince3-May-11 3:59 
Generalthank you for suggestion http://www.floresense.com/resc_cent... Pin
ambarishtv2-May-11 20:05
memberambarishtv2-May-11 20:05 
GeneralRe: Hi Anil. countrylist.csv file column has unsupported data fo... Pin
ambarishtv7-May-11 22:00
memberambarishtv7-May-11 22:00 
GeneralProvide the link to download CSV file. Pin
Prasanta_Prince1-May-11 6:09
memberPrasanta_Prince1-May-11 6:09 
GeneralRe: When I run the following BULK INSERT Tbl_COUNTRY FROM 'C:\... Pin
Anil Srivastava7-May-11 10:15
memberAnil Srivastava7-May-11 10:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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.150624.2 | Last Updated 8 May 2011
Article Copyright 2011 by ambarishtv
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid