Hi Chandradev,
Greetings from Syncfusion.
We suggest you to achieve your requirement (to save the changes in Database) using OnBatchSave event of the Grid. This event will be triggered when saving all the changes (as a whole) in Grid. In the event argument we can get the changes performed in Grid like changed record, added record, deleted records etc. Using this we can update the changes in Database.
Refer the below code example.
|
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">
<GridEvents OnBatchSave="OnSave" TValue="Order"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings>
. . . . . .
</SfGrid>
@code{
public List<Order> Orders { get; set; }
public void OnSave(BeforeBatchSaveArgs<Order> Args)
{
var BatchChanges = Args.BatchChanges;
if(BatchChanges.AddedRecords.Count > 0)
{
//Insert data into your database
}
if(BatchChanges.ChangedRecords.Count > 0)
{
//update changes into your database
}
if(BatchChanges.DeletedRecords.Count > 0)
{
//delete record from your database
}
} |
Refer our UG documentation for your reference
If you are using Custom way of binding, then please refer the below documentation for reference.
Regards,
Rahul