private void ButtonDeleteMapping_Click(object sender, EventArgs e) { if (GridViewSupplierServType.FocusedRowHandle >= 0) { SupplierServiceType suppServType = (SupplierServiceType)GridViewSupplierServType.GetFocusedRow(); //Removing from the collection just removes the object from its parent, but does not mark //it for deletion, effectively orphaning it. This will cause foreign key errors when saving. //To flag for deletion, delete it from the context as well. _selectedRecord.SupplierServiceType.Remove(suppServType); _context.SupplierServiceType.DeleteObject(suppServType); BindSupplierServType(); } }
private void FinalizeBindings() { BindingSource.EndEdit(); GridViewSupplierServType.CloseEditor(); GridViewSupplierServType.UpdateCurrentRow(); //Set the city code for each mapping just in case for (int rowCtr = 0; rowCtr < GridViewSupplierServType.DataRowCount; rowCtr++) { SupplierServiceType suppServType = (SupplierServiceType)GridViewSupplierServType.GetRow(rowCtr); suppServType.ServType_Code = TextEditCode.Text ?? string.Empty; } BindingSourceSupplierServType.EndEdit(); }