changing grid DataSource

2 posts, 0 answers
  1. Tim R
    Tim R avatar
    133 posts
    Member since:
    Feb 2006

    Posted 14 Jun 2013 Link to this post

    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?

     

  2. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 19 Jun 2013 Link to this post

    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?
Back to Top