private void Fill_Colleges() { SqlConnection con = new SqlConnection(_connString); con.Open(); SqlCommand cmd = new SqlCommand("select * from Colleges ORDER BY College_Code", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); DDLColleges.DataSource = ds; DDLColleges.DataTextField = "College_Code"; DDLColleges.DataValueField = "CollegeName"; DDLColleges.DataBind(); DDLColleges.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--------- Select ---------", "0")); con.Close(); }
protected void DDLColleges_DataBound(object sender, EventArgs e) { DropDownList ddl = sender as DropDownList; if (ddl != null) { foreach (ListItem li in ddl.Items) { li.Attributes["Title"] = li.Value.ToUpper(); li.Attributes.Add("style", "color:#1B3E74"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)