protected void Page_Load(object sender, EventArgs e)
        {
            CountryList.DataSource = new[]
            {
                new CountryDTO()
                {
                    Id = 1, Name = "Czech Republic"
                },
                new CountryDTO()
                {
                    Id = 2, Name = "Germany"
                },
                new CountryDTO()
                {
                    Id = 3, Name = "USA"
                }
            };
            CountryList.DataBind();

            // read selected item IDs
            var selectedIds = CountryList.Items.OfType <ListItem>()
                              .Where(i => i.Selected)
                              .Select(i => int.Parse(i.Value))
                              .ToList();
        }
Exemple #2
0
    protected void RegionList_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        foreach (DataRow datarow in RegionsSet.Tables["Regions"].Rows)
        {
            if (datarow.RowState != DataRowState.Deleted)
            {
                if ((int)datarow["ID"] == Convert.ToInt32(RegionList.SelectedValue))
                {
                    RegionName.Text = (string)datarow["Region"];
                    break;
                }
            }
        }

        CountriesSet.Clear();
        try
        {
            if (Convert.ToInt32(RegionList.SelectedValue) != 0)
            {
                CountriesAdapter.SelectCommand.Parameters["@RegionID"].Value = Convert.ToInt32(RegionList.SelectedValue);
                //lock (CommonFunctions.Connection)
                CountriesAdapter.Fill(CountriesSet);
            }
        }
        catch (Exception)
        {
        }

        CountryList.DataBind();
        CountryList2.DataBind();
        CountryList_SelectedIndexChanged(CountryList, EventArgs.Empty);
    }
        /// <summary>
        /// Binds the countries list.
        /// </summary>
        /// <param name="shippingRow">The shipping row.</param>
        private void BindCountriesList(ShippingMethodDto.ShippingMethodRow shippingRow)
        {
            List <CountryDto.CountryRow> leftCountries  = new List <CountryDto.CountryRow>();
            List <CountryDto.CountryRow> rightCountries = new List <CountryDto.CountryRow>();

            CountryDto dto = CountryManager.GetCountries(true);

            bool allToLeft = false;             // if true, then add all countries to the left list

            if (shippingRow != null)
            {
                ShippingMethodDto.ShippingCountryRow[] restrictedCountryRows = shippingRow.GetShippingCountryRows();
                if (restrictedCountryRows != null && restrictedCountryRows.Length > 0)
                {
                    foreach (CountryDto.CountryRow countryRow in dto.Country)
                    {
                        bool found = false;
                        foreach (ShippingMethodDto.ShippingCountryRow restrictedCountryRow in restrictedCountryRows)
                        {
                            if (countryRow.CountryId == restrictedCountryRow.CountryId)
                            {
                                found = true;
                                break;
                            }
                        }

                        if (found)
                        {
                            rightCountries.Add(countryRow);
                        }
                        else
                        {
                            leftCountries.Add(countryRow);
                        }
                    }

                    CountryList.LeftDataSource  = leftCountries;
                    CountryList.RightDataSource = rightCountries;
                }
                else
                {
                    // add all countries to the left list
                    allToLeft = true;
                }
            }
            else
            {
                allToLeft = true;
            }

            if (allToLeft)
            {
                // add all countries to the left list
                CountryList.LeftDataSource = dto.Country;
            }

            CountryList.DataBind();
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        UserSession us = Session["User"] as UserSession;

        try
        {
            UserSession.IsAuthorized(defined, Session["User"] as UserSession);
        }
        catch (UnauthorizedAccessException)
        {
            Response.Redirect(UserManager.GetDefaultPage(UserType.Invalid));
            return;
        }

        if (!IsPostBack)
        {
            DataTable dt = LearningManagementSystem.Components.User.GetRegisteredCountryList();

            CountryList.DataSource     = dt;
            CountryList.DataTextField  = "Country";
            CountryList.DataValueField = "Country_Id";
            CountryList.DataBind();

            CountryList1.DataSource     = dt;
            CountryList1.DataTextField  = "Country";
            CountryList1.DataValueField = "Country_Id";
            CountryList1.DataBind();

            CountryList2.DataSource     = dt;
            CountryList2.DataTextField  = "Country";
            CountryList2.DataValueField = "Country_Id";
            CountryList2.DataBind();

            CountryList3.DataSource     = dt;
            CountryList3.DataTextField  = "Country";
            CountryList3.DataValueField = "Country_Id";
            CountryList3.DataBind();

            CountryList4.DataSource     = dt;
            CountryList4.DataTextField  = "Country";
            CountryList4.DataValueField = "Country_Id";
            CountryList4.DataBind();

            CountryList5.DataSource     = dt;
            CountryList5.DataTextField  = "Country";
            CountryList5.DataValueField = "Country_Id";
            CountryList5.DataBind();

            CountryList6.DataSource     = dt;
            CountryList6.DataTextField  = "Country";
            CountryList6.DataValueField = "Country_Id";
            CountryList6.DataBind();
        }
    }
Exemple #5
0
        public void Bind_ddlCountry()
        {
            con.Open();
            SqlCommand    com = new SqlCommand("SELECT COUNTRY_CODE,COUNTRY_NAME FROM COUNTRY", con);
            SqlDataReader dr  = com.ExecuteReader();

            CountryList.DataSource = dr;
            CountryList.Items.Clear();
            CountryList.Items.Add("...Please select Country...");
            CountryList.DataTextField  = "COUNTRY_NAME";
            CountryList.DataValueField = "COUNTRY_CODE";
            CountryList.DataBind();
            con.Close();
        }
Exemple #6
0
        protected void ContinantList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ContinantList.SelectedIndex == 0)
            {
                CountryList.SelectedIndex = 0;
                CountryList.Enabled       = false;

                CityList.SelectedIndex = 0;
                CityList.Enabled       = false;
            }

            else
            {
                CountryList.Enabled = true;
                SqlParameter parameter = new SqlParameter("@countryId", ContinantList.SelectedValue);
                DataSet      ds        = GetData("GetCountry", parameter);
                CountryList.DataSource = ds;
                CountryList.DataBind();
                ListItem country = new ListItem("Select the Country", "-1");
                CountryList.Items.Insert(0, country);
                CityList.SelectedIndex = 0;
                CityList.Enabled       = false;
            }
        }