Hi,
I have a problem that happens sometimes, and I can't find the source of the problem:
In the software I develope:
1. I open a screen for the first time2. I change a cell in a grid of type dropDownList3. I try to save with SubmitChanges()
and the change is not saved!!!
I work with LINQ.
Waiting for your advise,Thanks ahead,Yael
What triggers the save? My guess is that you are using a toolbar button or some other control that does not take focus. Since the grid never loses focus, the changes in the current cell still in edit mode are not saved to the grid.
You can usually get around this by using the grid's PerformAction method to ExitEditMode and then perhaps also call grid.UpdateData to commit the current changes before you try to save.
Before "Save", I did the following:
1. set the focus on another control.
2. myGrid.PerformAction(UltraGridAction.ExitEditMode);
3. myGrid.UpdateData();
Still my change was not saved :(
I work with LINQ, so I don't use AcceptChanges etc.
We use dataContext.SubmitChanges() in order to save the changes.
As I wrote before, the dataContext.GetChangeSet() returns no changes.... :(
I'm not an expect on LINQ, but it probably depends on what kind of LINQ you are using, what it's returning, and what you are using as the DataSource of the grid.
The grid can only update the local data source using the BindingManager and the IBindingList or IList interface. The DataSource itself is responsible for tracking changes (if it wants to do so).
When using LINQ, I have often found that (depending on what type of LINQ you are using and where the data is coming from) that you can often get it to work better by wrapping the data source in a BindingSource.
In some cases, binding directly to data retrieved from LINQ won't work at all and you have to copy the data into some other structure more suitable for binding.
I use a binding source in my code.
I debugged some more, and found this:
I made a change in a cell in the grid, and in the grid_cellChange event:
The binding source was updated, but the dataContext.getChangeSet() returned no changes!
--> Means that the dataContext did not track the change of the binding source!
Note that this happens only in the first time, if I'll insert now a row to the grid for example, the getChangeSet() will return 1 insert.
After considerable efforts, I found what causes the problem:
In the initialize_layout event of the grid, I wrote this line:
this.DisplayLayout.Override.RowSizing = RowSizing.AutoFixed;
After I commented this line, the grid was saved with no problem!
I have no clue how this line caused the problem, but now it works fine.If you have an idea I would like to hear!
Thanks,Yael
Hi Yael,
There's no reason why the RowSizing property should have any effect on saving the data.