コード例 #1
0
    protected void BillingCountryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList countryDropDownList = (DropDownList)sender;

        try
        {
            ServiceAccess serviceLoader = ServiceAccess.GetInstance();

            BillingStateDropDownList.Items.Clear();
            int countryId = Convert.ToInt32(countryDropDownList.SelectedValue);

            if (countryId == 0)
            {
                BillingStateDropDownList.Items.Add(new ListItem("Choose a State", ""));
            }
            else
            {
                CommonService.CommonService     commonService = serviceLoader.GetCommon();
                IList <CommonService.StateInfo> states        = commonService.GetStates(countryId);

                BillingStateDropDownList.DataSource     = states;
                BillingStateDropDownList.DataValueField = "StateId";
                BillingStateDropDownList.DataTextField  = "Name";
                BillingStateDropDownList.DataBind();
            }
        }
        catch (Exception ex)
        {
        }
    }
コード例 #2
0
    protected void CountryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList countryDropDownList = (DropDownList)sender;

        try
        {
            ServiceAccess serviceLoader = ServiceAccess.GetInstance();

            StateDropDownList.Items.Clear();
            int countryId = Convert.ToInt32(countryDropDownList.SelectedValue);

            if (countryId == 0)
            {
                StateDropDownList.Items.Add(new ListItem("&lt;Select a State&gt;", "0"));
            }
            else
            {
                CommonService.CommonService     commonService = serviceLoader.GetCommon();
                IList <CommonService.StateInfo> states        = commonService.GetStates(countryId);

                StateDropDownList.DataSource     = states;
                StateDropDownList.DataValueField = "StateId";
                StateDropDownList.DataTextField  = "Name";
                StateDropDownList.DataBind();
            }
        }
        catch (Exception ex)
        {
            log.Error("UNKNOWN ERROR:", ex);
        }
    }