System.Data Namespace DataRow Class
Returns the parent row of a DataRow using a specified DataRelation name.
[ VB ]
Overloads Public Function GetParentRow ( _
ByVal relationName As String _
) As DataRow
[ C# ]
public DataRow GetParentRow (
string relationName
);
[ C++ ]
public: DataRow* GetParentRow (
String* relationName
);
[ JScript ]
public function GetParentRow (
relationName : String
) : DataRow;
- relationName
- The RelationName of a DataRelation.
The current row's parent DataRow.
The following example uses the GetParentRow property to return the child DataRow objects for every child DataRelation in a DataTable. The value of each column in the row is then printed.
private void GetParentRowForTable ( DataTable thisTable, string relationName ) {
if ( thisTable == null ) {return;}
// for each row in the table, print column 1 of the parent DataRow.
DataRow parentRow;
foreach ( DataRow row in thisTable.Rows ) {
parentRow = row.GetParentRow ( relationName );
Response.Write ( "\t child row: " + row [ 1 ] );
Response.Write ( "\t parent row: " + parentRow [ 1 ] + "<br>" );
}
}
private void CallGetParentRowForTable ( ) {
// an example of calling the function.
DataTable thisTable = myDataSet.Tables [ "Products" ];
DataRelation relation = thisTable.ParentRelations [ 0 ];
GetParentRowForTable ( thisTable, relation );
}
DataRow Members DataRow.GetParentRow Overload List GetChildRows GetParentRows Relations