I have simple C# WPF application which gets the data from the database into WPF datagrid via an Entity Framework model. In direction from database to WPF DataGrid everything works fine.
My problem is the opposite direction from datagrid to the database. I'd like to update the database after every cell update, so I work in CellEditEnding
event.
The code below doesn't throw any exception but no WPF datagrid cell changes are saved into the database (DGISPRSDataView
is my WPF datagrid)
Please can you tell me, where is the problem? What am I missing? How can I connect datagrid changes into data model and to database? Or is there any callback from server - as is in Silverlight case - (Entity model + DomainContext class)
Thanks a lot!
private void DGISPRSDataView_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
try
{
ReviewsEntities dataEntity = new RreviewsEntities(); //DataContext
this.DGISPRSDataView.DataContext = dataEntity.Form_output_test;
dataEntity.SaveChanges();
MessageBox.Show("Update succesfully end");
}
catch (Exception err)
{
MessageBox.Show(err.ToString());
}
}