asp.net.ph

DataTable.ParentRelations Property

System.Data Namespace   DataTable Class


Returns the collection of parent relations for this DataTable.

Syntax


Script [ DataRelationCollection variable = ] DataTable.ParentRelations

Property Value


variable Returns the DataRelationCollection that contains the parent relations for the table; otherwise a null value if no DataRelation objects exist.

The property is read only with no default value.

Example

The following example uses the ParentRelations property to return each parent DataRelation in a DataTable. Each relation is then used as an argument in the GetParentRows method of the DataRow to return an array of rows. The value of each column in the row is then printed.

Private void ParentRelationsDemo ( DataTable myTable ) {

   DataRow [ ] arrRows;

   foreach ( DataRelation rel in myTable.ParentRelations ) {
      foreach ( DataRow row in myTable.Rows ) {
         arrRows = row.GetParentRows ( rel );
         // print values of rows.
        for ( int i = 0; i < arrRows.Length; i++ ) {
            foreach ( DataColumn col in myTable.Columns ) {
               Response.Write ( arrRows [ ] [ col ] );
           }
        }
     }
   }
}
  C# VB

See Also

DataTable Members   ChildRelations   DataRelation   DataSet   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