Adding country list control to my webpart using code behind

Gideon Gontor asked on January 8, 2020 14:44

i created a webpart and would like to add kentico country selector to it using code behind. i need help on how to.

Correct Answer

Trevor Fayas answered on January 8, 2020 16:24

You can use Kentico's API, i believe it's CountryInfoProvider.GetCountries()

You can append other stuff, such as .OrderBy("CountryDisplayName"), etc.

just foreach through these and fill up your repeater. Something like below, note may be syntax errors, just free handing it.

foreach(CountryInfo Country in CountryInfoProvider.GetCountries()) {
    ddlMyDropDown.Items.Add(new ListItem(Country.CountryName, Country.TwoLetterCode));
}
0 votesVote for this answer Unmark Correct answer

Recent Answers


Gideon Gontor answered on January 8, 2020 16:34

Thanks very much for your help

0 votesVote for this answer Mark as a Correct answer

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