Hello everyone,
I want to please know how I could do a dropdown list in ASP.NET that automatically includes all countries. I know how to make a simple drop-down list in asp.net, but it would be exhausting to have to fill by myself all over the world.
Should I do an import?
Please help.

VulpesRank #55 · 29.2K reputationPosted Dec 11, 2014, 1:43 AM EST
http://msdn.microsoft.com/en-us/library/system.web.mvc.controllerbase.viewbag(v=vs.118).aspx
ViewBag is a dynamic object whose properties you can define yourself. So we should be able to give it a Countries property and then retrieve the value of that property in the view.
Just wondering whether you have the controller code in the right place?
According to the above link, the whole method should be:
VulpesRank #55 · 29.2K reputationPosted Dec 9, 2014, 6:08 AM EST
http://justinchronicles.wordpress.com/2012/03/15/how-to-get-list-of-countries-defined-in-iso-3166-1-programatically-by-c-shar/
It should then be just a matter of binding this list to your DropDownList control.
Ramsès Zogning II79 reputationPosted Dec 9, 2014, 8:06 AM EST
How can i join RegionInfo to my dropdownlist ?
Joginder BangerRank #360 · 7K reputationPosted Dec 9, 2014, 9:12 AM EST
if you want region info select any list , then you make a event the selectedIndexed_changed.
VulpesRank #55 · 29.2K reputationPosted Dec 9, 2014, 9:17 AM EST
To bind to the DDL, you'd then need something like this:
Ramsès Zogning II79 reputationPosted Dec 9, 2014, 12:21 PM EST
Ramsès Zogning II79 reputationPosted Dec 9, 2014, 12:23 PM EST
VulpesRank #55 · 29.2K reputationPosted Dec 10, 2014, 12:52 PM EST
Frankly, I don't know a great deal about the latter but, after studying an example of populating a DropDownList I found on the internet (http://forums.asp.net/t/1959753.aspx?Best+way+to+populate+drop+down+lists+MVC+4+razor+) , I hope the following will work:
Ramsès Zogning II79 reputationPosted Dec 11, 2014, 12:49 AM EST
i try after the school and i will tell you
Ramsès Zogning II79 reputationPosted Dec 11, 2014, 1:07 AM EST
This is the error : Il n'y a aucun élément ViewData de type « IEnumerable
thk u very much for your help Sirs
i will continue to fine the solution
Ramsès Zogning II79 reputationPosted Dec 11, 2014, 1:00 PM EST
I finally get out.
The error was in another code for my controller, so the code you have given me is good. you are a champion. I could also connect the list of countries to one of my model table and everything works well.
Please, can you also help me about this:
Internationalization of a web application VCM 4 razor.
link:
http://www.c-sharpcorner.com/Forums/Thread/278453/internationalization-of-a-web-application-vcm-4-razor.aspx
thank you