private void BindingMethodForCountry()
        {
            try
            {
                using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ToString()))
                {
                    cn.Open();
                    using (SqlDataAdapter adp = new SqlDataAdapter("Select * from TblCountry", cn))
                    {
                        DataSet ds = new DataSet();
                        adp.Fill(ds);

                        DropDownListCountry.DataSource     = ds;
                        DropDownListCountry.DataValueField = "CountryId";
                        DropDownListCountry.DataTextField  = "CountryName";
                        DropDownListCountry.DataBind();

                        DropDownListCountry.Items.Insert(0, new ListItem("-----------Select Country-----------", "0"));
                        DropDownListState.Items.Insert(0, new ListItem("------------Select State------------", "0"));
                        DropDownListCity.Items.Insert(0, new ListItem("-------------Select City-------------", "0"));

                        if (DropDownListCountry.SelectedValue == "0")  //If Country is not selected then clear State DropDownList
                        {
                            DropDownListState.Items.Clear();
                            DropDownListState.Items.Insert(0, new ListItem("------------Select State------------", "0")); //index, listItem item(text,value)
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //used to call the method from FetchCountries
         DropDownListCountry.DataSource = Countries.country_name_list();
         DropDownListCountry.DataBind();
     }
 }
        public void BindCountries()
        {
            CountryCache cache             = new CountryCache(this.Context);
            List <CSBusiness.Country> list = (List <CSBusiness.Country>)cache.Value;

            DropDownListCountry.DataSource     = list;
            DropDownListCountry.DataTextField  = "Name";
            DropDownListCountry.DataValueField = "CountryId";
            DropDownListCountry.DataBind();
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtStartDate.Text = System.DateTime.Now.ToString("MM/dd/yyyy");


                // Categories
                List <JsonCintGeneral> categories;

                if (Session["ListCategories"] == null)
                {
                    categories = JsonConvert.DeserializeObject <List <JsonCintGeneral> >(jsonGET("https://api.cintworks.net/ordering/reference/survey/categories"));
                    Session["ListCategories"] = categories;
                }
                else
                {
                    categories = (List <JsonCintGeneral>)Session["ListCategories"];
                }

                List <JsonCintGeneral> categoriesSortedList = categories.OrderBy(o => o.name).ToList();

                DropDownListCategory.DataSource     = categoriesSortedList;
                DropDownListCategory.DataTextField  = "name";
                DropDownListCategory.DataValueField = "id";
                DropDownListCategory.DataBind();

                List <JsonCintGeneral> countries;


                if (Session["ListCountries"] == null)
                {
                    countries = JsonConvert.DeserializeObject <List <JsonCintGeneral> >(jsonGET("https://api.cintworks.net/ordering/reference/countries"));
                    Session["ListCountries"] = countries;
                }
                else
                {
                    countries = (List <JsonCintGeneral>)Session["ListCountries"];
                }

                List <JsonCintGeneral> countriesSortedList = countries.OrderBy(o => o.name).ToList();
                DropDownListCountry.DataSource     = countriesSortedList;
                DropDownListCountry.DataTextField  = "name";
                DropDownListCountry.DataValueField = "id";
                DropDownListCountry.DataBind();

                DropDownListCountry.SelectedValue = "22";
            }
        }
Exemple #5
0
        /// <summary>
        /// Gets the list of Countries
        /// </summary>
        private void GetCountries()
        {
            SqlDataReader drCountries = DataProvider.GetCountryList();

            DropDownListCountry.DataSource     = drCountries;
            DropDownListCountry.DataTextField  = "COUNTRY_NAME";
            DropDownListCountry.DataValueField = "COUNTRY_ID";
            DropDownListCountry.DataBind();
            ListItem blankCountry = DropDownListCountry.Items.FindByValue("-1");

            if (blankCountry != null)
            {
                DropDownListCountry.Items.Remove(blankCountry);
            }
            drCountries.Close();
        }
Exemple #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!Page.IsPostBack)
         {
             ErpDataContext db        = new ErpDataContext();
             DataTable      dtCountry = new DataTable();
             var            result    = db.SpCountry();
             dtCountry = Globals.ObtainDataTableFromIEnumerable(result);
             DropDownListCountry.DataSource     = dtCountry;
             DropDownListCountry.DataValueField = "CountryName";
             DropDownListCountry.DataTextField  = "CountryName";
             DropDownListCountry.DataBind();
             DropDownListCountry.Items.Insert(0, new ListItem("Select Country", ""));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #7
0
 // DropDownList DropDownListCountry;
 protected void Page_Load(object sender, EventArgs e)
 {
     DropDownListCountry.DataSource = GetCountry();
     DropDownListCountry.DataBind();
 }