This documentation is archived and is not being maintained.

DataRow.GetParentRows Method

Gets the parent rows of a DataRow.

Overload List

Gets the parent rows of a DataRow using the specified DataRelation.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Function GetParentRows(DataRelation) As DataRow()
[C#] public DataRow[] GetParentRows(DataRelation);
[C++] public: DataRow* GetParentRows(DataRelation*) [];
[JScript] public function GetParentRows(DataRelation) : DataRow[];

Gets the parent rows of a DataRow using the specified RelationName of a DataRelation.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Function GetParentRows(String) As DataRow()
[C#] public DataRow[] GetParentRows(string);
[C++] public: DataRow* GetParentRows(String*) [];
[JScript] public function GetParentRows(String) : DataRow[];

Gets the parent rows of a DataRow using the specified DataRelation, and DataRowVersion.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Function GetParentRows(DataRelation, DataRowVersion) As DataRow()
[C#] public DataRow[] GetParentRows(DataRelation, DataRowVersion);
[C++] public: DataRow* GetParentRows(DataRelation*, DataRowVersion) [];
[JScript] public function GetParentRows(DataRelation, DataRowVersion) : DataRow[];

Gets the parent rows of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Function GetParentRows(String, DataRowVersion) As DataRow()
[C#] public DataRow[] GetParentRows(string, DataRowVersion);
[C++] public: DataRow* GetParentRows(String*, DataRowVersion) [];
[JScript] public function GetParentRows(String, DataRowVersion) : DataRow[];

Example

[Visual Basic] The following example uses the GetParentRows to return the child DataRow objects for every child DataRelation in a DataTable. The value of each column in the row is then printed.

[Visual Basic] Note   This example shows how to use one of the overloaded versions of GetParentRows. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Private Sub GetChildRowsFromDataRelation(myTable As DataTable, ver As DataRowVersion)
    Dim dr As DataRelation
    Dim arrRows() As DataRow
    Dim r As DataRow
    Dim i As Integer
    Dim dc As DataColumn 
 
    For Each dr In myTable.ParentRelations
      For Each r In myTable.Rows
          arrRows = r.GetParentRows(dr, ver)
          ' Print values of rows.
          For i = 0 To arrRows.GetUpperBound(0)
             For Each dc in myTable.Columns
                Console.WriteLine(arrRows(i)(dc.ColumnName))
             Next dc
          Next i
       Next r
    Next dr
 End Sub

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

DataRow Class | DataRow Members | System.Data Namespace

Show: