We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Save changes from sfdatagrid to database using entity framework

I have sfdatagrid bound to entity framework. How do i save or update changes to database with ef.

1 Reply

SA Saravanan Ayyanar Syncfusion Team January 27, 2020 02:23 PM UTC

Hi Mariusz Juszkiewicz, 
 
Thank you for using Syncfusion controls. 
 
You can save the changes and you add the new row by below mentioned events. 
 
Save Data changes  
You can save the data changes by CurrentCellEndEdit event. 
 
C#: 
private void SfDataGrid1_CurrentCellEndEdit(object sender, Syncfusion.WinForms.DataGrid.Events.CurrentCellEndEditEventArgs e) 
 { 
     MessageBox.Show("CurrentCellEndEdit"); 
     //You can add your entity codes here to save the data. 
 } 
 
 
Add New Row 
You can save the add new row changes by RecordsCollectionChanged event. 
 
C#: 
private void Records_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
 { 
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) 
     { 
         var record = e.NewItems[0] as RecordEntry; 
         //You can add your entity codes here to add the data . 
     } 
 } 
 
 
Sample Link: 
 
You can refer the Entity Framework connection from below UG documentation,  
  
  
For more details refer below links,  
  
  
  
Please let us know, if you need further assistance on this.  
 
Regards, 
Saravanan A. 


Loader.
Live Chat Icon For mobile
Up arrow icon