Datagrid Second Update

Datagrid Second Update

Old forum URL: forums.lhotka.net/forums/t/3345.aspx


stanc posted on Tuesday, August 07, 2007

I have an ERL bound to a DataGridView. I can modify any row once and have the update take. I can also add a row and have it save. Deletes work fine. My problem comes in when I try to modify a row that has already been saved once. All additional updates do not get fired.

I've looked through the post and found one related to this, but I couldn't figure out how to implement the suggestion. Rocky posted that I would have to handle the ListChanged event and raise the PropertyHasChanged in the root object.

If anyone has any help, I would appreciate it.

stan

stanc replied on Wednesday, August 08, 2007

I've tracked the issue down to BusinessBase.AcceptChangesComplete. The first time an item is updated, it's parent is the ERL. The next time through it has no parent. This makes some sense because the save actually retuns a new object (although I don't know why it would lose its reference to the parent).

I do not mark my BusinessBase objects as children (I haven't looked, but I guess the add method for the ERL does it). If I do add MarkAsChild, then I cannot call MyBase.Save.

  1. Is there a way to reset the parent after the save comes back?
  2. Should I be marking my objects as children, and overriding MyBase.Save?
  3. Or is there something I'm missing?

 

RockfordLhotka replied on Wednesday, August 08, 2007

This could be a bug. Are you using a remote data portal configuration?

stanc replied on Wednesday, August 08, 2007

I am using a remote data portal. I've been trying to step through to see where I lose the parent, and I can't track it down. When it gets to the DP_U, it doesn't have the reference to the parent at that point, but it appears to be back after the call. And a light goes off, I was checking the parent of the object making the call and not the returned object. I was checking in the Save of the BO.

So it seems, it is losing the reference when it crosses te data portal.

Any ideas?

RockfordLhotka replied on Thursday, August 09, 2007

Yes, definitely a bug in ERLB. The following code is missing:

 

  ''' <summary>

  ''' Replaces an item in the list.

  ''' </summary>

  ''' <param name="index">Index at which the item was replaced.</param>

  ''' <param name="item">New item.</param>

  Protected Overrides Sub SetItem(ByVal index As Integer, ByVal item As T)

    item.SetParent(Me)

    MyBase.SetItem(index, item)

  End Sub

 

Add that and the problem should be resolved – I’ll fix it in 3.0.2.

 

Rocky

 

 

From: stanc [mailto:cslanet@lhotka.net]
Sent: Wednesday, August 08, 2007 11:43 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Datagrid Second Update

 

I am using a remote data portal. I've been trying to step through to see where I lose the parent, and I can't track it down. When it gets to the DP_U, it doesn't have the reference to the parent at that point, but it appears to be back after the call. And a light goes off, I was checking the parent of the object making the call and not the returned object. I was checking in the Save of the BO.

So it seems, it is losing the reference when it crosses te data portal.

Any ideas?



stanc replied on Thursday, August 09, 2007

Thanks for the reply and the solution. This one was driving a little batty.

pandelaras replied on Tuesday, October 30, 2007

great work! That one was bugging me too

 

Copyright (c) Marimer LLC