Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
455
How to re-select a row after the grid is reloaded?
posted

I meet a problem that after I reload the datasource of a grid, the active row automatically jump to the first row of the grid. Is it possible to reselect the row after the datasource is reloaded. Thanks!

 Tom

  • 469350
    Verified Answer
    Offline posted

    It depends what you mean by "reload the datasource". 

    Whatever you are doing must either be re-setting the DataSource property of the grid or causing the data source to fire a Reset notification. Either way, the rows in the grid are all destroyed and a completely new set of rows is created. So you will not only lose the ActiveRow, you will lose any selected rows or expanded rows, too, because those rows no longer exist. Therefore, you should generally try to avoid re-setting the data source if possible. 

    If you want to maintain the active row, then you would have to store some kind of key information about that row, then find the row and make it active again after the reset. You can't store the Row object itself, since it won't be the same row.