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

How to remove and clear entire records from SfDataGrid?

I'm using SfDataGrid in Xamarin forms and I want to clear the entire records from the SfDataGrid. Basically, I want to make the grid empty again. How can I do that in C#?

1 Reply

AN Ashok N Syncfusion Team July 14, 2017 06:12 AM UTC

Hi Gangatharan, 

Thanks for contacting Syncfusion support. 

You can achieve your requirement by clearing the Binding ItemsSource. Please refer the below code example : 

<ContentPage.BindingContext> 
    <local:ViewModel x:Name="viewModel" /> 
</ContentPage.BindingContext> 

<sfgrid:SfDataGrid x:Name="dataGrid"  
            ItemsSource="{Binding OrdersInfo}" > 
</sfgrid:SfDataGrid> 

private void ClearRecords_Clicked(object sender, EventArgs e) 
{ 
    // Clear the records from view 
    viewModel.OrdersInfo.Clear(); 
} 


Regards, 
Ashok 


Loader.
Live Chat Icon For mobile
Up arrow icon