try this
if ( ddlsearchby.SelectedItem.Text == "All")
{
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("Select * from tbl ", con);
SqlCommandBuilder cmd = new SqlCommandBuilder(da);
da.Fill(dt);
dgvitemDetails.DataSource = dt;
}
else
{
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("Select * from tbl where " + ddlsearchby.SelectedItem.text + " = '" + txtSearch.Text + "'", con);
SqlCommandBuilder cmd = new SqlCommandBuilder(da);
da.Fill(dt);
dgvitemDetails.DataSource = dt;
}
complete example then visit link
http://hightechnology.in/how-to-filter-gridview-records-with-dropdownlist-selection/[
^]