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
155
Reselecting row after updating it and clearing/reloading the grid with the UltraDataSource
posted

I have a scenario in which users can select a row and click a button to open a pop-up with the information pertaining to that row as well as a couple of textboxes for editing (and then saving) new values. When data is saved the pop-up closes then focus returns to the main form which clears the ultraDataSource, sets the grid to the new cleared out data source. The datasource is then populated by looping through data received from a web service. The sort on the grid is then refreshed and the grid is in view. My first idea to reselect the last selected row was to use the following code...

 int lastSelected = 0;

if (ultraGrid.ActiveRow != null)

     lastSelected = ultraGrid.ActiveRow.ListIndex;

 

    // Reload/Refresh data here

   ultraGrid.ActiveRow  = ultraGrid.Rows[lastSelected];

 

This doesn't work however, because at this point index positions have shifted due to the refresh/re-sorting of data. Does anyone have any ideas as about how to do this?

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    You would have to store some key information about the row, like the PrimaryKey or some identify field in the data source. Then loop through the rows and find the matching row.

Children
No Data