asp.net.ph

DataRow.GetChildRows Method

System.Data Namespace   DataRow Class


Returns the child rows of a DataRow.

Overload List

1. Returns the child rows of a DataRow using a specified DataRelation object.

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

3. Returns a version of the child rows of a DataRow using a specified DataRelation object.

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


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.

NOTE: This example uses one of the overloaded versions of GetChildRows. For other examples that may be available, see the individual overload topics.

// 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   ChildRelations   DataRelation   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