Insert Child data with the Parent data on the same page RRS feed

  • Question

  • User-554100711 posted

    I'm using Visual Studio 2008 SP1, .NET Framework 3.5 SP1, DDE website.

    I have a need to insert child data along with the parent data on the same insert page. (eg, Order and Order Details). I looked at Steve's article on Advanced field templates to integrate the child data/form with the parent form in the Edit mode. But I need to have the same thing done in the insert mode as well. My initial thought to do is to store all child records added on this combined insert page in session without actually saving them to the database (since there is no FK OrderDetails.Order.OrderId available yet) and only save the child data to the database after the Insert of the parent data. The data inserts to parent and child tables should occur as one transaction.

    Any thoughts or direction on this is much appreciated.


    Wednesday, April 29, 2009 9:33 AM

All replies

  • User-330204900 posted

    Your problem is that you don't have anything to relate to until you save the paretn record you could cause the form to post back to the edit page after the parent record has been inserted and the add the children.

    Wednesday, April 29, 2009 10:59 AM
  • User-554100711 posted

    Thanks for the idea.

    I was able to get around this by making the PK of the parent table a GUID. I then generate the new guid in the OnSavingChanges event handler and use it to save the child data as well.

    What I am now running into is an issue setting the correct datacontext for the EntityDataSource control in the FieldTemplate ChildrenGrid. Steve, do you have any equivalent of your ChildrenGrid article that works with EntityDataSource?


    Thursday, April 30, 2009 4:01 PM
  • User-330204900 posted

    Not at the moment I'm just getting to know EFbut I think when VS2010 Beta 2 or RC is out I will do that, or if a project that requires it comes up sooner. [:D]

    Thursday, April 30, 2009 4:07 PM
  • User-1384485915 posted

    Steve, following your instructinos on http://csharpbits.notaclue.net/2008/10/dynamic-data-custom-pages_08.html I got it right displaying and editing children data on the same page as the parent. For instance, OrderDetails inside the Order view. But I'm having a load of trouble inserting data in it! For instance, I'm trying to insert new products in that order, but without success. Problems with the Linqdatasource and all sorts of things. Can you help me on that one?

    By the way, your blog rocks on DD!

    Tuesday, February 15, 2011 3:09 PM
  • User-330204900 posted

    We seem to have lost the direct mail from here [:(] send me an e-mail and I will send you my latest code it's EF but using the old version you should be able to fix it up.

    Thursday, February 17, 2011 11:55 AM