Proper way to use the csladatasource, formview, and objects

Proper way to use the csladatasource, formview, and objects

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


fark posted on Monday, March 01, 2010

I've been searching for an example of how to use my child objects with the Asp.Net formview.  I have found several examples the show Mother Daughter in windows forms but nothing in asp.net.  What I am trying to accomplish is:

1. I have a parent object hooked to a csladatasource (which I shall name parentdatasource) and a formview hooked to the parent datasource.

2. I have an object that is a child to the parent hooked to a csla datasource (which I shall name childdatasource) and a formview hooked to the child datasource. 

3.  I need to be able to hit a button labeled save or insert and have it cause the parent and child to insert their data.  I have done this before without CSLA and am now converting this application to CSLA.  Before I used to have a button that the user would click and it would run objectdatasource.Insert() for the "parent" data and get the foreign key passed to the child object datasource and then run objectdatasource2.Insert();

I don't see an insert() method on the csladatasource and when I use the insert button on the formview it inserts the parent just fine but does not trigger the childcsladatasource's insert.  How do I get the child data inserted?  I tried nesting the formviews but that did not work either.  I'm guessing there is some code that I need to add to the parentdatasource insert but I am new to CSLA and this is my first experience with a child object.  I am using CSLAGen to create my objects.

Any help to steer me in the right direction would be much appreciated.

Copyright (c) Marimer LLC