How can I access the information of that row when the data in the row changes?

Hi,


I want to update the same data in my database when user changes data in a row in SfDataGrid.


The CurrentCellEndEdit event is triggered when inline data changes. But I couldn't find how to access the information of the changed row in this activity. Can you provide some guidance on this?


3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team February 14, 2022 02:36 PM UTC

Hi Özgür,

Your requirement to access the information of the changed row  in SfDataGrid can be achieved by using View.GetPropertyAccessProvider.GetValue method in SfDatGrid. Please refer the below code snippet, 

private void OnCurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs e) 
{ 
            var dataGrid = sender as SfDataGrid; 
 
            var provider = dataGrid.View.GetPropertyAccessProvider(); 
 
            //here get the information of the changed row by using RowIndex 
            var record = dataGrid.GetRecordAtRowIndex(e.RowColumnIndex.RowIndex); 
 
            if (record == null) 
                return; 
 
            //here get the column by using column Index 
            var column = dataGrid.Columns[dataGrid.ResolveToGridVisibleColumnIndex(e.RowColumnIndex.ColumnIndex)]; 
 
            //here get the changed cell value 
            var cellValue = provider.GetValue(record, column.MappingName); 
 
            MessageBox.Show("Changed data in a row : " + cellValue); 
} 


Please let us know if you have any concerns in this. 

Regards, 
Vijayarasan S 


Marked as answer

VS Vijayarasan Sivanandham Syncfusion Team February 17, 2022 10:06 AM UTC

Hi Özgür,

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.

Regards,
Vijayarasan S



ÖZ Özgür February 17, 2022 10:23 AM UTC

Hi Vijayarasan Sivanandham  ,

Thank you for help.


Loader.
Up arrow icon