Saving the SfDataGrid row values to the Database
I have created a DataGrid using SfDatagrid. However, I am not getting any useful links regarding saving the data to a MySql Database. Kindly, Let me know
Attachment: frm_SO_e02b5bb9.rar
Attachment: frm_SO_e02b5bb9.rar
SIGN IN To post a reply.
3 Replies
SS
Susmitha Sundar
Syncfusion Team
March 4, 2020 12:39 PM UTC
Hi Boopathi,
Thank you for using Syncfusion controls.
You can save the value of the SfDataGrid rows to the database using the SfDataGrid.CurrentCellEndEdit and SfDataGrid.RowValidating events. If you want to save the cell value, you can use the SfDataGrid.CurrentCellEndEdit event. And if you want to save the entire row value, you can use the SfDataGrid.RowValidating event. Please refer to the code below,
event.
And while editing, you can save existing
|
AddHandler() sfDataGrid1.RowValidating, AddressOf sfDataGrid1_RowValidating
AddHandler sfDataGrid1.CurrentCellEndEdit, AddressOf SfDataGrid1_CurrentCellEndEdit
Private Sub sfDataGrid1_RowValidating(ByVal sender As Object, ByVal e As RowValidatingEventArgs)
Dim data = TryCast(e.DataRow.RowData, OrderInfo)
'Here you can update the entire row values to database
End If
End Sub
Private Sub sfDataGrid1_CurrentCellEndEdit(ByVal sender As Object, ByVal e As Syncfusion.WinForms.DataGrid.Events.CurrentCellEndEditEventArgs)
If Not sfDataGrid1.IsAddNewRowIndex(sfDataGrid1.CurrentCell.RowIndex) Then
'Here you can update the cell values to database
End If
End Sub |
We have checked your provided code snippets. You are using the DetailsViewDataGrid, so you can listen the child grid events by parent grid event handlers by setting the NotifyEventsToParentDataGrid property. Please refer the below UG link,
|
' To notify the DetailsView events to parent DataGrid events.
firstLevelNestedGrid.NotifyEventsToParentDataGrid = True |
Please let us know if you need further assistance on this.
Regards,
Susmitha S
BO
Boopathi
March 16, 2020 07:32 AM UTC
Dear Susmitha Sundar,
Attachment: SfDataGrid_with_relations_97ff88f3.rar
Thanks for your response!
I'm not cleared with these solutions, Because, I have created sfdatagrid with relations and it's sub Datagrid.
Actually, I needed is to save each sfdatagrid and its related subgrid values to the Database.
Please find the attachment for your reference.
Attachment: SfDataGrid_with_relations_97ff88f3.rar
SS
Susmitha Sundar
Syncfusion Team
March 17, 2020 08:57 AM UTC
Hi Boopathi,
Thank you for your update.
As per our previous update, the SfDataGrid.CurrentCellEndEdit and SfDataGrid.RowValidating raised for DetailsViewDataGrid. Also, if you enable the SfDataGrid.NotifyEventsToParentDataGrid, you can save the updated value for parent and child data grid in this event by using MySQL commands. Please refer the below links for SQL command update,
Please let us know if you need further assistance on this.
Regards,
Susmitha S
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
BO Boopathi
- Mar 3, 2020 10:30 AM UTC
- Mar 17, 2020 08:57 AM UTC