I have a Gridview that I want to filter. My gridview is in an update panel and my filter button is not. On button click i have the following
protected void bttnfilter_Click(object sender, ImageClickEventArgs e)
{
if (TextBox1.Text != "")
{
SqlDataSource1.SelectCommand += " and field like '%' + @param + '%'";
SqlConnection conn = new SqlConnection(SqlDataSource1.ConnectionString );
SqlCommand cmd = new SqlCommand(SqlDataSource1.SelectCommand, conn);
cmd.Parameters.Add(new SqlParameter("@param", TextBox1.Text));
}
}
So i add to the select command but I'm getting an error. How should I go about this? I don't want to use dynamic sql.
The Error Reads Incorrect Syntax near 'and'