コード例 #1
0
        private void LookupCities(string state, bool autoDefault = false)
        {
            if (ShippingProvider != null)
            {
                var lookupResults = ShippingProvider.GetCitiesForState(ProductsBase.CountryCode, state);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var city in lookupResults)
                    {
                        string[] item = city.Split('-');
                        ddlCity.Items.Add(new ListItem(item[1], item[0]));
                    }
                    ddlCity.Items.Insert(0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    ddlCity.SelectedIndex = (autoDefault && (ddlCity.Items.Count > 0)) ? 1 : 0;

                    if (ddlCity.SelectedIndex > 0)
                    {
                        LookupOther(ddlState.SelectedItem.Value, ddlCity.SelectedItem.Value, autoDefault);
                    }
                }
                else
                {
                    ddlState.Focus();
                }
            }
        }