asp.net.ph

DataRow.GetParentRow Method ( String, DataRowVersion )

System.Data Namespace   DataRow Class


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

[ VB ]
Overloads Public Function GetParentRow ( _
   ByVal relationName As String, _
   ByVal version As DataRowVersion _
) As DataRow

[ C# ]
public DataRow GetParentRow (
   string relationName,
   DataRowVersion version
);

[ C++ ]
public: DataRow* GetParentRow (
   String* relationName,
   DataRowVersion version
);

[ JScript ]
public function GetParentRow (
   relationName : String,
   version : DataRowVersion
) : DataRow;

Parameters

relationName
The RelationName of a DataRelation.
version
One of the DataRowVersion values.

Example

The following example uses the GetParentRow property to print a value from each parent row of each DataRow in a DataTable.

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 );
}
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