GetParentRows
DataRow[]parentRows
= DataRow.GetParentRows(DataRelationdr
); DataRow[]parentRows
= DataRow.GetParentRows(StringrelationName
); DataRow[]parentRows
= DataRow.GetParentRows(DataRelation, DataRowVersiondrv
); DataRow[]parentRows
= DataRow.GetParentRows(StringrelationName
, DataRowVersiondrv
);
Gets an array of DataRow
objects that are the
parent rows of the current row, based on a
DataRelation
.
parentRows
Returns an array of DataRow
objects.
dr
The DataRelation
to use when retrieving the parent
row.
relationName
The name of the DataRelation
to use when
retrieving the parent row.
drv
One of the DataRowVersion
enumeration values
described in Table 25-5 in the next section.
The following example uses the GetParentRow( )
method to retrieve the Cocktails
in which each
Ingredient
is used:
// iterate through all of the Ingredient rows foreach(DataRow rowIngredient in ds.Tables["Ingredient"].Rows) { // iterate through the Cocktail rows for the specified Ingredient foreach(DataRow rowCocktail in rowIngredient.GetParentRows( "Cocktail_Ingredient")) { // ... code to process the Cocktail row } }