AddChild
Adds a new DataRow to the named parent/child relationship. If the named relationship exists, the supplied DataRow will be appended to the existing DataRow collection. Otherwise, a new collection will be created with the supplied DataRow as its only element.
Syntax
public void AddChild(DataRow parentRow, string name, DataRow newChild)
Parameters
- Name - the name of the parent/child relationship (e.g., "Flood Plain Data," "References, " "Used By," etc.)
- DataRow - the DataRow to be added to the relationship.
Results
None.
Example
EnhancedDataTable dataTable = new EnhancedDataTable();
dataTable.Columns.Add(new DataColumn("AddressLine1", System.Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("City", System.Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("StateProvince", System.Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("PostalCode", System.Type.GetType("System.String")));
DataRow row = dataTable.NewRow();
row[0] = "510 S Coit St";
row[1] = "Florence";
row[2] = "SC";
row[3] = "29501-5221";
EnhancedDataTable childDataTable = new EnhancedDataTable();
childDataTable.Columns.Add(new DataColumn("AddressLine2", System.Type.GetType("System.String")));
childDataTable.Columns.Add(new DataColumn("City", System.Type.GetType("System.String")));
childDataTable.Columns.Add(new DataColumn("StateProvince", System.Type.GetType("System.String")));
childDataTable.Columns.Add(new DataColumn("PostalCode", System.Type.GetType("System.String")));
DataRow childRow = childDataTable.NewRow();
childRow[0] = "241 Ne C St";
childRow[1] = "Willamina";
childRow[2] = "OR";
childRow[3] = "97396-2714";
dataTable.AddChild(row, "Child1", childRow);
dataTable.Rows.Add(row);