Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto set parent key field in child -- when?
Message
De
19/08/2008 10:13:13
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
18/08/2008 20:55:12
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 3.0
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01339607
Message ID:
01339925
Vues:
18
>>Larry,
>>
>>>Hi Kevin/All,
>>>assuming (yeah I know...) I've set correctly as per the docs in my child object.partial ForeignParentKeyField="myparentid" and AutoSaveOnParentSaved=true, and in my form I've done parent.RegisterChildBizObj(Parent, "Parent").
>>>
>>>When adding a new row (mmButtonNew) to a child object, can you tell me when/in what event the child.parentid will get set automatically?
>>>
>>>Currently seems to fail after a save attempt (field required) but gets filled after I acknowledge the error dialog, so I can then save.
>>>
>>>I can take care of it by setting the field myself in a postnewrow event, but I'd like to handle the mm way if possible.
>>>
>>>thanks,
>>>
>>>-Larry
>>
>>in the business object there is a method called PopulateForeignParentKeyField(). This is called from:
>>SaveEntity()
>>SaveEntityList()
>>and
>>SaveDataSet()
>>
>>When you use the mmButtonSave in a form you will probably hit the latter of those methods after several of the overloads. I would guess that either the ParentKeyID is not getting set or some other thing is failing along the way. I would probably put a breakpoint in the SaveDataSet(string tableName, int currentRow) method early and step through the overloads until you see what is happening when you get to the call to PopulateForeignParentKeyField method. You will likely break here more than once, so you could just continue when it is saving your parent record.
>>
>>Tim
>
>
>Hi Tim,
>thanks, so it's definately after save is initiated (in my case .SaveEntityList), which is why I wasn't seeing it after adding a new row (not saved yet). Guess I read that somewhere, and it makes sense.
>
>-Larry

There is an overload for NewRow that allows you to pass in a Default Values object if that would be helpful. What was the error dialog you were getting if it was occuring before the save?
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform