More in this section
Forums / Developing with Sitefinity / Dropdowns with the list of country and state

Dropdowns with the list of country and state

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 0 answered
  1. Ravi
    Ravi avatar
    11 posts
    17 Jan 2012
    19 Jan 2012
    Link to this post

    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.

  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    02 Jan 2018
    21 Jan 2012
    Link to this post
    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
  3. Michael
    Michael avatar
    18 posts
    26 Jan 2011
    22 Feb 2012
    Link to this post
    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?
  4. Jesse
    Jesse avatar
    31 posts
    08 Nov 2010
    22 Feb 2012
    Link to this post
    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. 
4 posts, 0 answered