Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Having trouble wiht a child grid
Message
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Having trouble wiht a child grid
Miscellaneous
Thread ID:
00910957
Message ID:
00910957
Views:
61
I've got a nearly classic situation I stole right from the jumpstart where there is a child grid on the properties page of an mmMaintenanceForm. I placed a mmButtonNew on the form and set the BindingSource property. I then needed to pre-populate a couple of the columns with data specific to this form. I think the way I did it is pretty ugly, but it looks like this:

//Set defaults for new DataRow
dsDrugDose = oDrugDose.GetCurrentDataSet();
int rowNum = dsDrugDose.Tables["lkup_drug_dose"].Rows.Count - 1;
DataRow myRow = dsDrugDose.Tables["lkup_drug_dose"].Rows[rowNum];
myRow["Dose"] = "";
myRow["Default_Dose"] = 0;

this.grdForms.NavigateData(mmNavigate.Last);
this.grdForms.Focus();

Everything works except that when I add a new parent record, then add new child records without first saving the parent, I get constraint violations in the database. Is there a way I can force the parent record to be written to the db first? Adding new child records to an existing parent works great.

Also, if there is something a little more elegant for setting default values for columns in the new row, I'd love to use it!

Thanks in advance,
Mike
Next
Reply
Map
View

Click here to load this message in the networking platform