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

                    if (ddlState.SelectedIndex > 0)
                    {
                        LookupCities(ddlState.SelectedItem.Value, autoDefault);
                    }
                }
            }
        }