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

Iterate over selected rows and change their cell values

For example, my SfDataGrid looks like this:


I want to add a button that will change all currently selected rows' "bool" column to "true". How do I do this? I couldn't find anything related in the documentation.

1 Reply

MA Mohanram Anbukkarasu Syncfusion Team November 28, 2019 02:19 PM UTC

Hi Michal,   
Thanks for contacting Syncfusion support.    
Your requirement to change the values of a specific column for all the selected rows on a button click can be achieved as shown in the below code example.   
Code example:    
private void Button_Click(object sender, RoutedEventArgs e)   
    foreach(var item in this.dataGrid.SelectedItems)   
        if (!(item as EmployeeInfo).IsAvailable)   
            (item as EmployeeInfo).IsAvailable = true;   

We have prepared a sample using the above code example to replicate your scenario and it is available in the below link for your reference.   
Please let us know if you require further other assistance from us.    
Mohanram A  

Live Chat Icon For mobile
Up arrow icon