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 to checkbox to database

I have a sfdatagrid with a gridcheckboxcolumn.  I need to update the database field bound to the checkbox when the checkbox becomes checked or unchecked.  I have tried the gridcheckbox and a checkbox imbedded in a datatemplate, but cannot get the database to be updated.

3 Replies

JG Jai Ganesh S Syncfusion Team September 11, 2017 12:16 PM UTC

Hi David, 
 
You can get the underlying record values and update it to database fields while we check/uncheck the GridCheckBoxColumn by wiring the CurrentCellValueChanged event.  
 
this.sfGrid.CurrentCellValueChanged += sfGrid_CurrentCellValueChanged; 
 
void sfGrid_CurrentCellValueChanged(object sender, Syncfusion.UI.Xaml.Grid.CurrentCellValueChangedEventArgs args) 
{ 
    int columnIndex = this.sfGrid.ResolveToGridVisibleColumnIndex(args.RowColumnIndex.ColumnIndex); 
 
    if (this.sfGrid.Columns[columnIndex].CellType == "CheckBox") 
    { 
        var record = args.Record; 
    } 
} 
 
Sample: 
 
Regards, 
Jai Ganesh S 



DG David Gammon September 11, 2017 04:38 PM UTC

Can you show an example using visual basic?



GT Gnanasownthari Thirugnanam Syncfusion Team September 13, 2017 02:24 AM UTC

Hi David, 
 
We have prepared the sample for your requirement in VB as per your update, you can download the sample from below mentioned location. 
 
VB 
AddHandler Me.sfGrid.CurrentCellValueChanged, AddressOf sfGrid_CurrentCellValueChanged 
Private Sub sfGrid_CurrentCellValueChanged(ByVal sender As Object, ByVal args As Syncfusion.UI.Xaml.Grid.CurrentCellValueChangedEventArgs) 
       Dim columnIndex As Integer = Me.sfGrid.ResolveToGridVisibleColumnIndex(args.RowColumnIndex.ColumnIndex) 
 
       If Me.sfGrid.Columns(columnIndex).CellType Is "CheckBox" Then 
              Dim record = args.Record 
       End If 
End Sub 
 
Sample location: 
 
Regards, 
Gnanasownthari T. 


Loader.
Live Chat Icon For mobile
Up arrow icon