General information
Category:
The Mere Mortals .NET Framework
Title:
Having trouble wiht a child grid
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only