private void toolBar_btnEdit_Click(object sender) { if (dgemployee.SelectedItem != null) { contact Employee_old = (contact)dgemployee.SelectedItem; Employee_old.IsSelected = true; Employee_old.State = EntityState.Modified; dbContext.Entry(Employee_old).State = EntityState.Modified; } else { toolBar.msgWarning("Please Select an Item"); } }