I have the following static method.
public static List<string> GetAutoCompleteData(string StudentId)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=.;Integrated Security=true;Initial Catalog=SMS"))
{
//using (SqlCommand cmd = new SqlCommand("select StudentId,StudentName from tblStudent where StudentId LIKE '%'+@SearchText+'%'", con))
using (SqlCommand cmd = new SqlCommand("select T1.StudentName,T1.StudentId from tblStudent T1 where StudentId LIKE '%'+@SearchText+'%' except select T2.StudentName, T2.StudentId from tblStudentAcademics T2 where T2.AcademicYear='" +Dropdownvalue + "'", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", StudentId);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(dr["StudentId"].ToString() + "-" + dr["StudentName"].ToString());
}
return result;
}
}
}
I need to write ddlAcadeic.selectedvalue.tostring() in place of Dropdownvalue.Help me