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
229
Update grid after editing
posted

Hi,

I have the following problem. I present the user a grid. This grid is a usercontrol with an UltraGrid and a BindingNavigator.

It is connect with the data like this:

this.oDataAdapter = new SqlDataAdapter();
this.oDataAdapter.SelectCommand = oCommand;
this.oDataAdapter.Fill(this.oTableGrid);
this.oBindingSource = new BindingSource();
this.oBindingSource.DataSource = this.oTableGrid;
this.ultraGrid1.DataSource = this.oBindingSource;
this.bindingNavigator1.BindingSource = this.oBindingSource;

Now when a row needs editing, the user doubleclicks and a form is generated ( my app is datadriven ).  For this form the data is first reread from the database.  I cannot share the BindingSource of the grid, as often a view is displayed and not every view is editable.
After editing, the modified data is written to the database, so I need to reread the data for the grid to be updated. Like this:

this.oTableGrid.Clear();
t
his.oDataAdapter.Fill(this.oTableGrid);

This works, but gives me the grid in the start position. A grouping is still active, but after rereading the data, the data of the previous expanded group needs to be expanded again.

Is there a way to restore the layout like how it was before editing? I have tried to do it with saving and loading a layout file

this.ultraGrid1.DisplayLayout.Save(Filename);

but this does not work in for me in this situation.
Another thing I have tried without success is this:

this.ultraGrid1.ActiveRow.Refresh(RefreshRow.ReloadData);
this.ultraGrid1.ActiveRow.Refresh(RefreshRow.RefreshDisplay);

Can anyone give me a hint how to solve this problem?

kind regards,

 

Erik Visser

Parents Reply Children
No Data