Skip to main content

Unanswered Question Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submittedRSS Feed

(0)

callmeknud
callmeknud

Member

Member

16 points

84 Posts

Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

Hello, 

the ItemsSource of my DG is set like this: myDG.ItemsSource = context.Projects;


If the User clicks on the Save Button (context.SubmitChanges();) while a cell is still in editing mode the following exception is thrown:

Entity 'Projects : 3' is currently being edited and has uncommitted changes. A call to BeginEdit must be followed by a call to EndEdit or CancelEdit before changes can be submitted.

I tried myDG.EndEdit(); but the error still occurs ...?

xusun
xusun

Participant

Participant

1363 points

216 Posts

Microsoft

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

I don't think there's myDG.EndEdit method.  Did you call myDG.CommitEdit(DataGridEditingUnit.Row, true).  This will commit the changes to the Entity and Exit the editing mode.

Thanks,
Xun Sun - MSFT

callmeknud
callmeknud

Member

Member

16 points

84 Posts

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

sorry i already called myDG.CommitEdit() not EndEdit but even if i call it with (DataGridEditingUnit.Row, true)  i get the same error.

xusun
xusun

Participant

Participant

1363 points

216 Posts

Microsoft

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

Did you do something special?  Actually, even you don't call DG.CommitEdit, it should automatically do it for you while you leave the focus from DataGrid.  Could you post some code here? 

Thanks,
Xun Sun - MSFT

Jonathan Shen – MSFT
Jonathan...

All-Star

All-Star

31167 points

3,020 Posts

Microsoft

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

Hi Callmeknud,

How's your issue going?   Has it been resolved yet?   I agree with Xun Sun,  if it doesn't work, would you please share a tiny repro here.  Thanks.

Best regards,

Jonathan

Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Firewalker2396
Firewalk...

Member

Member

2 points

9 Posts

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

I don't know if this is still an issue or not, but check the return value returned from CommitEdit(). If it's false, make sure that no validation you have in place is preventing the commit to the entity.

callmeknud
callmeknud

Member

Member

16 points

84 Posts

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

Sorry that i didn't reply, but i really had no time.

The return value is indeed false, but when i look into the entity when the error occurs, the entity base shows:
HasValidationErrors = 0

callmeknud
callmeknud

Member

Member

16 points

84 Posts

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

The DataGrid AutoGenerateColums ist set to false and my Columns look like the following:

<
data:DataGridTextColumn Header="Sa" Binding="{Binding Sa, Mode=TwoWay,
Converter={StaticResource FormatConverter},ConverterCulture=de-DE,
ConverterParameter=\{0:0.00\}}"/>

I will have a look at the Converter, maybe that causes the Problem.

What i don't really understand is, that the error says the Entity is currently being edited but i only tell the DataGrid to commit the changes.
Is that right or do i somehow have to tell the Entity to commit the changes?

callmeknud
callmeknud

Member

Member

16 points

84 Posts

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

before context.SubmitChanges() i inserted the following lines and it seems to work, but is this intended?

IEditableObject SelectedProject = myDG.SelectedItem as Web.Project;
SelectedProject.EndEdit();

xusun
xusun

Participant

Participant

1363 points

216 Posts

Microsoft

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

Do you mind to send me a sample of your app?  I'd like to know where the BeginEdit was called.

Thanks,
Xun Sun - MSFT

thanhhh
thanhhh

Member

Member

2 points

1 Posts

Re: Entity is currently being edited and has uncommitted changes - EndEdit before changes can be submitted

Hello,

Before context.SubmitChanges(), you inserted lines of code following:

IEditableObject editableObject = project as IEditableObject; 
editableObject.EndEdit(); 

context.SubmitChanges();
Hope this help can solve your problems.

Regards

Thanh.

  • Unanswered Question
  • Answered Question
  • Announcement