DataSource of SfListView

How to clear DataSource of SfListView programmatically?


1 Reply

SM Shalini Maragathavel Syncfusion Team September 1, 2021 11:54 AM UTC

Hi Sergiush, 

Greetings from Syncfusion support.
 
Based on your query, we could understand that you need to clear the datasource of the ListView component. You can achieve your requirement by setting the ListView datasource value as null as demonstrated in the below code snippet. 
 
 
    <SfButton CssClass="e-primary" OnClick="cleardata">Clear data</SfButton> 
<div class="control-section"> 
    
    <div id="group-list"> 
        <h4>Default ListView</h4> 
       
        <SfListView DataSource="@Data" @ref="@SfList" TValue="DataModel"> 
        </SfListView> 
    </div> 
</div> 
@code{ 
    SfListView<DataModel> SfList; 
    public void cleardata() 
    { 
 
        Data = null;  
        
    } 
} 

Please find the below sample for your reference
 

Please get back to us if you need further assistance.

Regards,
Shalini M. 


Loader.
Up arrow icon