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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I save changes made in the Grid into the database?

 

When the user makes changes in the grid, like editing a row, deleting a row or adding a new row, these changes are immediately saved in the bound data set. There are two ways in which changes can be saved to the underlying database.

Option 1:

It is standard practice to include a Save button (or some other UI element) in the page which could be used by the user to confirm all the changes.And in the event handler for the Save button, you can call Update on the data adapter to force changes into the database:

C#

this.oleDbDataAdapter1.Update(this.dataSetCustomers1);

VB

Me.oleDbDataAdapter1.Update(Me.dataSetCustomers1)

Option 2:

If the changes need to be saved into the database as soon as the user is done editing a row, deleting a row or adding a new row, then you can listen to the following events and call Update on the data adapter, as shown:

C#

// This will be called when the user edits or adds a new row.

private void GridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)

{

if(e.Action == CurrentRecordAction.EndEditComplete)

{

this.oleDbDataAdapter1.Update(this.dataSetCustomers1);

}

}

// This will be called when the user deletes a row

private void GridGroupingControl1_BarButtonItemClicked(object source, Syncfusion.Web.UI.WebControls.Grid.Grouping.ButtonBarItemClickEventArgs e)

{

if(e.ButtonBarItem.ButtonBarItemType==ButtonBarItemType.DeleteRow)

 {

  {

   Record curRecord = this.GridGroupingControl1.Table.CurrentRecord;

   curRecord.Delete();

this.oleDbDataAdapter1.Update(this.dataSetCustomers1);

  }

  }

}

VB

' This will be called when the user edits or adds a new row.

Private Sub GridGroupingControl1_CurrentRecordContextChange(ByVal sender As Object, ByVal e As Syncfusion.Grouping.CurrentRecordContextChangeEventArgs)

If e.Action = CurrentRecordAction.EndEditComplete Then

Me.oleDbDataAdapter1.Update(Me.dataSetCustomers1)

End If

End Sub

' This will be called when the user deletes a row

Private Sub GridGroupingControl1_BarButtonItemClicked(ByVal source As Object, ByVal e As Syncfusion.Web.UI.WebControls.Grid.Grouping.ButtonBarItemClickEventArgs) Handles GridGroupingControl1.BarButtonItemClicked

      If e.ButtonBarItem.ButtonBarItemType = ButtonBarItemType.DeleteRow Then

        Dim curRecord As Record = Me.GridGroupingControl1.Table.CurrentRecord

curRecord.Delete()

Me.oleDbDataAdapter1.Update(Me.dataSetCustomers1)

      End If

End Sub

Article ID: Published Date: Last Revised Date: Platform: Control:
655 04/30/2011 07/10/2014 ASP.NET Web Forms (Classic) GridGroupingControl
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon