asp.net.ph

DataRow.GetChildRows Method ( String )

System.Data Namespace   DataRow Class


Returns the child rows of a DataRow using a specified DataRelation name.

[ VB ]
Overloads Public Function GetChildRows ( _
   ByVal relationName As String _
) As DataRow ( )

[ C# ]
public DataRow [ ] GetChildRows (
   string relationName
);

[ C++ ]
public: DataRow* GetChildRows (
   String* relationName
 ) [ ];

[ JScript ]
public function GetChildRows (
   relationName : String
) : DataRow [ ];

Parameters

relationName
The RelationName of the DataRelation to use.

Return Value

An array of DataRow objects ( or an array of length zero ).

Exceptions


Exception Type Condition
RowNotInTableException Occurs when the row does not belong to the table.
ArgumentException Occurs when the relation and row do not belong to the same table.

Remarks

In a DataSet, the collection of all DataRelation objects for the data set is returned by the Relations method. The DataTable also contains a collection of DataRelation objects, returned by the ChildRelations property.

Example

The following example uses the GetChildRows to return the child DataRow objects from the Products table, for every parent DataRow from the Categories table.

// iterate over parent rows ( Categories )

foreach ( DataRow category in ds.Tables [ 0 ].Rows; ) {
   html += "<br><div class='header' style='color:maroon'><h5>" + 
      category [ "CategoryName" ] + "</h5></div>";

   // begin table headers markup
   html += "<table class='child' width=75% align='center' cellspacing=1>";
   html += "<tr><th>Product Name</th>";
   ...
   // iterate over child rows ( Products )

   foreach ( DataRow product in category.GetChildRows ( "categoryId" ) ) {
      html += "<tr><td>" + product [ "ProductName" ] + "</td>";
      html += "<td>" + product [ "QuantityPerUnit" ] + "</td>";
      html += "<td align='right'>" + String.Format ( "{0:f2}", product [ "UnitPrice" ] ) + "</td>";
      html += "<td align='right'>" + product [ "UnitsInStock" ] + "</td></tr>";
   }
   html += "</table>";
}
  C# VB

 Show me 

See Also

DataRow Members   DataRow.GetChildRows Overload List 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