hi
i work under the KeyPress event and fill DataGridView in Data like this:
private void txtLookName_KeyPress(object sender, KeyPressEventArgs e){
SQL = "select id,aname from sq_table where aname like '%" + txtLookName.Text.Trim() + "%'";
dsView = new DataSet();
adp = new OleDbDataAdapter(SQL, Main.Conn);
adp.Fill(dsView, "sq_table");
adp.Dispose();
if (dsView.Tables["sq_table"].Rows.Count == 0)
{
dataGridView1.Visible = false;
return;
}
else
{
dataGridView1.Visible = true;
}
dataGridView1.DataSource = dsView.Tables["sq_table"].DefaultView;
}
but even if the txtLookName is empty or i got 0 rows i see the DataGridView
how to fix it ?