Get Country name from country ID

Matt Mason asked on July 28, 2014 20:49

I am trying to get the country name from the country ID. Any ideas on where that can be done?

Recent Answers


Brenden Kehren answered on July 28, 2014 21:06

Have you tried the CountryInfoor CountryInfoProvider?

CMS.Globalization.CountryInfo ci = CMS.Globalization.CountryInfoProvider.GetCountryInfo(245);
lbl.Text = ci.CountryName
2 votesVote for this answer Mark as a Correct answer

Matt Mason answered on July 28, 2014 21:17

That worked great - how about the state from the ID?

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on July 28, 2014 21:30

Same thing as Brenden had, but using the state class.


StateInfo si = StateInfoProvider.GetStateInfo(StateID); if (si != null) { lbl.Text = si.StateDisplayName; //You could use si.StateName too, but the display name will actually show up like "North Carolina" where the name would be NorthCarolina }


1 votesVote for this answer Mark as a Correct answer

Matt Mason answered on July 28, 2014 21:37

Perfect. Thanks guys!

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 29, 2014 01:48

@Matt, a Kentico standard for the API is the object definition is listed as < ObjectName >Info. The data methods (CRUD) options are all static and can be accessed by < ObjectName >InfoProvider. So if you want to get a user object you can go something like this:

UserInfo ui = UserInfoProvider.GetUser(userId);
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.