Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parent/Child Editing Ok, Not Adding
Message
From
14/09/2009 08:46:54
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01423691
Message ID:
01424095
Views:
44
Hi Eric,

A couple of things here. When a new Parent is added, how is the primary key being created? Is this done at the database or are you adding it in the HookSetDefaults method of the parent business object?

When you add a new parent record and then need to add the child record you should be able to just get the parents PK via the entity object rather than all this code you have below.

Plus you mention the AutoSaveOnParentSaved property being disabled but it is the ForeignParentKeyField property setting that causes the child objects foreign key to get populated with the parents PK. If you are not setting the parent tables PK in the HookSetDefaults method, I would consider setting it here so it is available for the business object to be able to populate the child record.

Hope some of that helps out.
Tim

>I got it to work, but it's kludgy and I'm sure not the proper way.
>
>The base of the problem seems to be that the ParentKeyValue property wasn't getting properly set in the child object before its Save. So I disabled the autoSaveOnParentSaved setting, and changed my save to this:
>
>        if (lReturn)
>        {
>            // Kludge! For new links
>            if (this.oMemberLink.Entity.numIndID == null || this.oMemberLink.Entity.numIndID == 0)
>            {
>                String cIdField = (lNewContact ? "newId" : "numIndId");
>                int iNewMemberId = Convert.ToInt32(this.oContact.DataSet.Tables[0].Rows[0][cIdField]);
>                this.oMemberLink.Entity.numIndID = iNewMemberId;
>                
>                this.oMemberLink.SaveEntity();
>            }
>            Response.Redirect("findName.aspx?txtFind=" + this.txtLastName.Text);
>        }
>
>
>And hurray, it works. Now, onto the next big problem (trying to get mmCheckBoxLists to populate properly...
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform