Articles in this section
Category / Section

How to save or cancel the edited DataForm data in .NET MAUI DataForm (SfDataForm)?

2 mins read

In the Syncfusion® .NET MAUI DataForm, you have the capability to either save or cancel edited data. This article demonstrates how to implement these functionalities.

C#:

When the Cancel button is clicked, the DataForm will reset to its initial state by creating a new data object.

private void OnCancelButtonClicked(object sender, EventArgs e)
{
   if (this.dataForm != null)
   {
       this.dataForm.DataObject = new DataFormModel();
   }
}

C#:

The Save button will commit the edited DataForm data using the Commit method. Ensure that the CommitMode is set to Manual.

private async void OnSaveButtonClicked(object sender, EventArgs e)
{
   if (this.dataForm != null && App.Current.MainPage != null)
   {
       this.dataForm.Validate();
       this.dataForm.Commit();
   }
}

Download the complete sample from GitHub.

Output:

On Save button clicked

OnSaved.gif

On Cancel button clicked

OnCancelled.gif

Conclusion:

I hope you enjoyed learning how to save or cancel the edited DataForm data in the .NET MAUI DataForm (SfDataForm).

Refer to our .NET MAUI DataForm feature tour page for its other groundbreaking feature representations. You can also explore our .NET MAUI DataForm documentation to understand how to present and manipulate data.

Check out our .NET MAUI components from the License and Downloads page for current customers. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI DataForm and other .NET MAUI components.

Please let us know in the following comments section if you have any queries or require clarification. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied