Same BO appear multiple instance in ChildBusinessObject collection


Author
Message
Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I have a form contains two business objects. I used ASPxGridView to bind to WebBBS which attach CHildBO. In Page_Load, I have code to set ChildBO.ParentBusinessObject = ParentBO if !IsPostback.



I am facing problem that, whenever I add new record to ASPxGridView, WebBBS.CreateShareAndAddBusinessObject() would be fired. In this method, it will clone the ChildBO; assign ChildBO.ParentBusinessObject to ClonedBO.ParentBusinessObject.



Whenever this happens, program try to access the ParentBO instance and add ClonedBO to its ChildBusinessObject collection. As all BOs are stored in Session, it cause existing ParentBO.ChildBusinessObjects retain and keep been added new ClonedBO.



It caused some error for that if I loop thru ParentBO.ChildBusienssObjects to do something.



Please advice.
Replies
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (938 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Chan,

We downloaded your sample and ran through it, but I'm not seeing the point of failure. Could you provide some additional information?

After wiring up your sample to work in our environment, I run your app and end up with a grid with a single record in it (the bottomost record from the database). After clicking new, I enter valid values into all fields and click update. The original grid is then populated with a single record containing my specified values. These values are not being saved back to the server (I assume a save is not being called here?). Regardless, the ChildBO count label stays at 1 which, as I understand it, is your point of failure.

Where are you placing your breakpoint? Do you intend for the data from a new record to be saved on the SQL server? Is your childBO issue being reflected by your label on your end?

Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

Sorry for misleading, the label would not be refreshed anyway.

As mentioned in previuos post, I placed breakpoint at line



'-- Set the parent business object of the instance object

loReturn.ParentBusinessObject = _BusinessObject.ParentBusinessObject



'-- Add the object to the list

Me._BusinessObjectList.Add(index, loReturn)





of BusinessBindingSource.CreateShareAndAddBusinessObject().



The data would not be saved to database as we need to call BO.Save manually.



I also uploaded video to show the behavour. http://www.visualsolutions.com.my/blog/chankk/bbs.zip



Please advice. urgent!

Thank you
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search