asp.net.ph

DataRow.GetParentRow Method ( DataRelation )

System.Data Namespace   DataRow Class


Returns the parent row of a DataRow using a specified DataRelation.

[ VB ]
Overloads Public Function GetParentRow ( _
   ByVal relation As DataRelation _
) As DataRow

[ C# ]
public DataRow GetParentRow (
   DataRelation relation
);

[ C++ ]
public: DataRow* GetParentRow (
   relation As DataRelation* relation
);

[ JScript ]
public function GetParentRow (
   relation : relation As DataRelation
) : DataRow;

Parameters

relation
The DataRelation to use.

Return Value

The row's parent DataRow.

Exceptions


Exception Type Condition
RowNotInTableException Occurs when the row does not belong to a table.
ArgumentNullException Occurs when the relation does not belong to the DataTable, or the row is a null reference.
InvalidConstraintException Occurs when this row does not belong to the DataRelation object's child table.

Example

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 ) {
   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 );
      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 );
}
See Also

DataRow Members   DataRow.GetParentRow Overload List   GetChildRows   GetParentRows   Relations Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph