protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { drp_city.Items.Add(new ListItem("Select City", "0", true)); drp_clg.Items.Add(new ListItem("Select College", "0", true)); drp_country_code.Items.Add(new ListItem("Select Country Code", "0", true)); DataSet ds = bl.get_city(); ds.Tables[0].DefaultView.Sort = "city_name"; drp_city.DataSource = ds.Tables[0]; drp_city.DataTextField = "city_name"; drp_city.DataValueField = "city_id"; drp_city.DataBind(); ds.Clear(); ds = bl.get_country_code(); ds.Tables[0].DefaultView.Sort = "country_name"; ds.Tables[0].Columns.Add("name_code"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ds.Tables[0].Rows[i][3] = ds.Tables[0].Rows[i][2] + " (" + ds.Tables[0].Rows[i][1] + ")"; } drp_country_code.DataSource = ds.Tables[0]; drp_country_code.DataTextField = "name_code"; drp_country_code.DataValueField = "country_code_id"; drp_country_code.DataBind(); ds.Clear(); } }
protected void databind_country_code() { DataSet ds = bl.get_country_code(); GridView1.DataSource = ds; GridView1.DataBind(); }