I have a DatagridView with two DataGridViewComboBoxCell:
What I want to do is when I select an administration from
Try to clear the value of employee cell before rebind it in the void
"selectEmployee", something like:
private void selectEmployee(int idAdministration)
{
if (con.State != ConnectionState.Open)
{
con.Open();
}
SqlCommand Cmd = new SqlCommand("SELECT * FROM Employee WHERE IdAdministration = @idAdministration", con);
Cmd.Parameters.AddWithValue("@idAdministration", idAdministration);
DataTable Dt = new DataTable();
Dt.Load(Cmd.ExecuteReader());
DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)dataGridView1.CurrentRow.Cells["Employee"];
cb.Value = null; //add this
cb.DataSource = Dt;
cb.DisplayMember = "Name";
cb.ValueMember = "CodeEmployee";
con.Close();
}