コード例 #1
0
        private void PopulateContinentsDropDownList()
        {
            ContinentsDropDownList.DataSource = GetData("spGetContinents", null);
            ContinentsDropDownList.DataBind();

            ListItem liContinent = new ListItem("Select Continent", "-1");

            ContinentsDropDownList.Items.Insert(0, liContinent);

            ListItem liCountries = new ListItem("Select Countries", "-1");

            CountriesDropDownList.Items.Insert(0, liCountries);

            ListItem liCities = new ListItem("Select Cities", "-1");

            CitiesDropDownList.Items.Insert(0, liCities);

            CountriesDropDownList.Enabled = false;
            CitiesDropDownList.Enabled    = false;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ContinentsDropDownList.DataSource     = GetData("spGetContinents", null);
                ContinentsDropDownList.DataTextField  = "ContinentName";
                ContinentsDropDownList.DataValueField = "ContinentId";
                ContinentsDropDownList.DataBind();


                ListItem listContinents = new ListItem("Select Continent", "-1");
                ContinentsDropDownList.Items.Insert(0, listContinents);

                ListItem listCountries = new ListItem("Select Country", "-1");
                CountriesDropDownList.Items.Insert(0, listCountries);

                ListItem listCities = new ListItem("Select City", "-1");
                CitiesDropDownList.Items.Insert(0, listCities);

                CountriesDropDownList.Enabled = false;
                CitiesDropDownList.Enabled    = false;
            }
        }