This is a migrated thread and some comments may be shown as answers.

changing grid DataSource

1 Answer 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tim R
Top achievements
Rank 1
Tim R asked on 14 Jun 2013, 04:08 PM
What is the best practice for repeatedly changing the grid's datasource when the structure varies? Should the rows be cleared and the columns list be cleared before resetting the DataSource to a new datatable?  Should the DataSource be set to null first?

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 19 Jun 2013, 10:02 AM
Hello Tim,

Thank you for writing.

In the straightforward case, you would just need to set the DataSource property of the grid to the new collection. However, if you have specified some columns, templates, relations, you might want to clear those too:
radGridView1.Rows.Clear();
radGridView1.Columns.Clear();
radGridView1.Relations.Clear();
radGridView1.Templates.Clear();

Let me know how this works for you.
 

Regards,
Stefan
Telerik
RadChart for WinForms is obsolete. Now what?
Tags
GridView
Asked by
Tim R
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or