Hi,
I think I see what is going on. You are not setting the "generate column" modules_Id.
See below:
private void add_PB_Click(object sender, EventArgs e)
{
try
{
//Assume DataSet is call ds.
DataRow parent = ds.Tables["modules"].Rows[0]; //Should do some checking here to see if row exists
int maxValue = 0;
DataRow dr = dtMod.NewRow();
//Set parent row!!!
dr["modules_Id"] = parent["modules_Id"];
if (dtMod.Rows.Count != 0)
{
foreach (DataRow row in dtMod.Rows)
{
if (Convert.ToInt16(row["moduleRecordID"]) > maxValue)
maxValue = Convert.ToInt16(row["moduleRecordID"]);
}
}
dr["pathLetter"] = "R";
dr["nodeNumber"] = "1";
dr["subNetNumber"] = "1";
dr["moduleRecordID"] = maxValue + 5;
dtMod.Rows.Add(dr);
mainForm.isDirty = true;
}
catch (SystemException err)
{
MessageBox.Show(err.Message);
}
}