コード例 #1
0
        protected void LoadCountry()
        {
            DataTable CountryDataTable = null;

            try
            {
                CountryDataTable = CountryBLL.CountryListByRegion(uoDropDownListRegion.SelectedValue, "");
                //                CountryDataTable = CountryBLL.CountryListByRegion(GlobalCode.Field2String(Session["Region"]), uoHiddenFieldCountryName.Value);
                uoDropDownListCountryPerRegion.Items.Clear();
                ListItem item = new ListItem("--Select Country--", "0");
                uoDropDownListCountryPerRegion.Items.Add(item);
                uoDropDownListCountryPerRegion.DataSource     = CountryDataTable;
                uoDropDownListCountryPerRegion.DataTextField  = "colCountryNameVarchar";
                uoDropDownListCountryPerRegion.DataValueField = "colCountryIDInt";
                uoDropDownListCountryPerRegion.DataBind();

                if (GlobalCode.Field2String(Session["Country"]) != "")
                {
                    if (uoDropDownListCountryPerRegion.Items.FindByValue(GlobalCode.Field2String(Session["Country"])) != null)
                    {
                        uoDropDownListCountryPerRegion.SelectedValue = GlobalCode.Field2String(Session["Country"]);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (CountryDataTable != null)
                {
                    CountryDataTable.Dispose();
                }
            }
        }