System.Data Namespace DataRow Class
Returns a version of the parent row of a DataRow using the specified DataRelation.
[ VB ]
Overloads Public Function GetParentRow ( _
ByVal relation As DataRelation, _
ByVal version As DataRowVersion _
) As DataRow
[ C# ]
public DataRow GetParentRow (
DataRelation relation,
DataRowVersion version
);
[ C++ ]
public: DataRow* GetParentRow (
DataRelation* relation,
DataRowVersion version
);
[ JScript ]
public function GetParentRow (
relation : DataRelation,
version : DataRowVersion
) : DataRow;
- relation
- The DataRelation to use.
- version
- One of the DataRowVersion values specifying the version of the data to get.
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, DataRelation relation,
DataRowVersion version ) {
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 ( relation, version );
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 ];
// print only original versions of parent rows.
GetParentRowForTable ( thisTable, relation,
DataRowVersion.Original );
}
DataRow Members DataRow.GetParentRow Overload List GetChildRows GetParentRows Relations