Dropdowns with the list of country and state
hi,
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.
Thanks
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"; target.DataBind(); var myCountriesCombo = new RadComboBox(); var myStatesCombo = new RadComboBox(); RadComboBoxExtensions.LoadWorldCountries(myCountriesCombo); RadComboBoxExtensions.LoadStatesAndProvinces(myStatesCombo);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?
Hey guys,
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 );