Dropdowns with the list of country and state

Posted by Community Admin on 04-Aug-2018 10:51

Dropdowns with the list of country and state

All Replies

Posted by Community Admin on 19-Jan-2012 00:00


I am new to sitefinity cms so can some one tell me how to add dropdown with the list of country and after the selection of country bind another dropdown with its respective state in another dropdown list.


Posted by Community Admin on 21-Jan-2012 00:00

Hi Ravi,

Are you developing a user/custom control that needs this functionality? If so you can reuse the existing countries configuration we have for our eCommerce module and simly create a method which takes a combo box and populates it with these countries. For example:

private void LoadCountries(RadComboBox target)
           target.DataSource = Config.Get<EcommerceConfig>().Countries.Values.Where(x => x.CountryIsActive == true).ToList().OrderBy(x=> x.Name);
           target.DataTextField = "Name";
           target.DataValueField = "IsoCode";
alternatively you can use our RadComboBox extensions like this:
var myCountriesCombo = new RadComboBox();
            var myStatesCombo = new RadComboBox();

All the best,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 22-Feb-2012 00:00

I have a need for a Country/State combo box as well but I don't have a subscription to the eCommerce module. Is the countries configuration functionality still available to me?

Posted by Community Admin on 22-Feb-2012 00:00

Hey guys,

Can this same approach be used for this if i want to use a dropdown list? I have to use a dropdown list with a List of Countries and bind it to the options in an Item of a Module I would have created in the back-end. I'm not sure what's the best approach can someone advise. I was thinking of actually adding each country as a field item in the Custom Field i would have created. I tried databinding based on the reference they gave for it but it doesn't seem to be binding. I've attached below the follow snippet of code i'd be using.

DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();    
            Type feedbackListingType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.FeedbackList.FeedbackListing");    
            DynamicContent feedbackListingItem = dynamicModuleManager.CreateDataItem(feedbackListingType);                      
            // This is how values for the properties are set    
            feedbackListingItem.SetValue("Title", "Feedback Item");    
            feedbackListingItem.SetValue("Owner", SecurityManager.GetCurrentUserId());    
            feedbackListingItem.SetValue("FeedbackTopic", feedbackTopic.Text);    
            feedbackListingItem.SetValue("PublicationDate", DateTime.Now);    
            feedbackListingItem.SetValue("FirstName", firstName.Text);    
            feedbackListingItem.SetValue("LastName", lastName.Text);    
            feedbackListingItem.SetValue("Address", address.Text);    
            feedbackListingItem.SetValue("City", city.Text);    
            feedbackListingItem.SetValue("Email", email.Text);    
            feedbackListingItem.SetValue("Phone", phone.Text);    
            feedbackListingItem.SetValue("MobilePhones", mobilePhone.Text);    
            feedbackListingItem.SetValue("Comments", comments.Text);    
            // Set the selected value     
            feedbackListingItem.SetValue("Country", new string[] countryList.SelectedValue );

"countryList" is the id of my dropdown list control. The other values are being set which are fine but when it comes to the country list it's not binding. Assistance is greatly needed. 

This thread is closed