//Load data from db into data grid view private void authorBindingNavigatorSaveItem_Click(object sender, EventArgs e) { Validate(); authorBindingSource.EndEdit(); try { dbcontext.SaveChanges(); } catch (DbEntityValidationException) { MessageBox.Show("FirstName and LastName must contain values", "Entity Validation Exception"); } }
// click event handler for the Save Button in the // BindingNavigator saves the changes made to the data private void authorBindingNavigatorSaveItem_Click(object sender, EventArgs e) { Validate(); // validate the input fields authorBindingSource.EndEdit(); // complete the current edit, if any // try to save changes try { dbcontext.SaveChanges(); // write changes to database file } // end try catch (DbEntityValidationException) { MessageBox.Show("FirstName and LastName must contain values", "Entity Validation Exception"); } // end catch } //end method for save button functionality