public static DropDownList dropDown(string col1,string col2,string tblName,DropDownList ddl) { SqlConnection con = Database.GetConnection(); SqlCommand cmd = new SqlCommand("select "+col1.Trim()+","+col2.Trim()+" from " + tblName.Trim() + "", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, tblName); ddl.DataSource = ds; ddl.DataTextField = col1; ddl.DataValueField = col2; ddl.DataBind(); return ddl; }
DataTextField
DataValueField
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)