AddChild
Agrega una nueva DataRow a la relación de elemento principal/secundario con nombre asignado. Si la relación con nombre asignado ya existe, la DataRow (Fila de datos) suministrada se anexará a la recopilación DataRow ya existente. De lo contrario, se creará una nueva recopilación con la DataRow suministrada como único elemento.
Sintaxis
public void AddChild(DataRow parentRow, string name, DataRow newChild)
Parámetros
- Name: el nombre de la relación de elemento principal/secundario (por ejemplo, "Datos de llanuras aluviales", "Referencias", "Usado por", etc.)
- DataRow: la fila de datos a agregar a la relación.
Resultados
Ninguno.
Ejemplo
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);