hi
em trying to fetch Employee information from db and load it in Gridview....i select departemnt name and Grade from dropdownlist and pass it in query buh it returns Invalid column name 'InformationTechnology' and Invalid column name 'Grade17'
String strCon = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection objcon = new SqlConnection(strCon);
objcon.Open();
// String str1 = "'"+dd_AdmViewProf_dep.SelectedItem.Value.ToString()"'";
string query = "Select * from EmpInfo where Department=" + dd_AdmViewProf_dep.SelectedItem.Value + " and Grade =" + dd_admViewProf_Grade.SelectedItem.Value;
//Response.Write(query);
// Response.End();
SqlDataAdapter adp = new SqlDataAdapter(query,objcon);
DataSet ds = new DataSet();
adp.Fill(ds, "EmpInfo");
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds.Tables["EmpInfo"].DefaultView;
GridView1.DataBind();
}
else {
Response.Write("unsucessful");
}
}