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

How to clear the GridControl?

I have a grid control where I am trying to update the table when I have a new set of values that I want to display on button click but I am unable to update the grid control with new values, I still see the old values.
I found a work around but I am not satisfied with that. The work around is to set the RowCount to 0 on every run.
Is there a better way to handle this scenario?
Thanks in advance!

1 Reply

MG Mohanraj Gunasekaran Syncfusion Team July 19, 2017 11:56 AM UTC

Hi JeeNew, 

Thanks for using Syncfusion product. 

Suggestion 1 

In order to update the GridControl by new set of values, you can use the PopulateValues method and then you should refresh the GridControl using Refresh method. Please refer to the below code example, 

Code example 
DataTable data = new DataTable(); 
CreateTable(data); 
//Repopulate the grid. 
this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, gridControl1.RowCount, gridControl1.ColCount), data); 
this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, gridControl1.RowCount, gridControl1.ColCount), data); 
this.gridControl1.Refresh(); 
 
 
 
Suggestion 2 
If you would like to update the specific cell value in button click. You can use the CellValue property. Please refer the below code example and the KB link, 

Code example 
this.gridControl1[1, 2].CellValue = "John"; 
 
 
 
Suggestion 3 
In order to clear the grid cell values, you can use the ClearCells method. Please refer to the below code example and the sample, 

Code example 
this.gridControl1.ClearCells(GridRangeInfo.Table(), true); 
 
 
Sample link: GridControl 
 
Regards, 
Mohanraj G 
 


Loader.
Up arrow icon