.NET Framework Class Library DataRow..::.GetParentRow Method (String)
Namespace:
System.Data
Assembly:
System.Data (in System.Data.dll)

Syntax
Public Function GetParentRow ( _
relationName As String _
) As DataRow
public DataRow GetParentRow(
string relationName
)
public:
DataRow^ GetParentRow(
String^ relationName
)
member GetParentRow :
relationName:string -> DataRow

Exceptions

Remarks

Examples
The following example uses the GetParentRow to print a value from each parent row of each DataRow in a DataTable.
Private Sub GetParentRowForTable( _
thisTable As DataTable, relation As String)
If thisTable Is Nothing Then
Return
End If
' For each row in the table, print column 1
' of the parent DataRow.
Dim parentRow As DataRow
Dim row As DataRow
For Each row In thisTable.Rows
parentRow = row.GetParentRow(relation)
Console.Write(ControlChars.Tab + " child row: " _
+ row(1).ToString())
Console.Write(ControlChars.Tab + " parent row: " _
+ parentRow(1).ToString() + ControlChars.Cr)
Next row
End Sub
Private Sub CallGetParentRowForTable()
' An example of calling the function.
Dim thisTable As DataTable = DataSet1.Tables("Products")
Dim relation As DataRelation = thisTable.ParentRelations(0)
GetParentRowForTable(thisTable, relation.RelationName)
End Sub
private void GetParentRowForTable(
DataTable thisTable, string relation)
{
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);
Console.Write("\table child row: " + row[1]);
Console.Write("\table parent row: " + parentRow[1]+ "\n");
}
}
private void CallGetParentRowForTable()
{
// An example of calling the function.
DataTable thisTable = DataSet1.Tables["Products"];
DataRelation relation = thisTable.ParentRelations[0];
GetParentRowForTable(thisTable, relation.RelationName);
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Biblioteca de clases de .NET Framework DataRow..::.GetParentRow (Método) (String)
Espacio de nombres:
System.Data
Ensamblado:
System.Data (en System.Data.dll)

Sintaxis
Public Function GetParentRow ( _
relationName As String _
) As DataRow
public DataRow GetParentRow(
string relationName
)
public:
DataRow^ GetParentRow(
String^ relationName
)
member GetParentRow :
relationName:string -> DataRow

Excepciones

Comentarios

Ejemplos
En el ejemplo siguiente se utiliza GetParentRow para imprimir un valor de cada fila primaria de cada DataRow en un DataTable.
Private Sub GetParentRowForTable( _
thisTable As DataTable, relation As String)
If thisTable Is Nothing Then
Return
End If
' For each row in the table, print column 1
' of the parent DataRow.
Dim parentRow As DataRow
Dim row As DataRow
For Each row In thisTable.Rows
parentRow = row.GetParentRow(relation)
Console.Write(ControlChars.Tab + " child row: " _
+ row(1).ToString())
Console.Write(ControlChars.Tab + " parent row: " _
+ parentRow(1).ToString() + ControlChars.Cr)
Next row
End Sub
Private Sub CallGetParentRowForTable()
' An example of calling the function.
Dim thisTable As DataTable = DataSet1.Tables("Products")
Dim relation As DataRelation = thisTable.ParentRelations(0)
GetParentRowForTable(thisTable, relation.RelationName)
End Sub
private void GetParentRowForTable(
DataTable thisTable, string relation)
{
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);
Console.Write("\table child row: " + row[1]);
Console.Write("\table parent row: " + parentRow[1]+ "\n");
}
}
private void CallGetParentRowForTable()
{
// An example of calling the function.
DataTable thisTable = DataSet1.Tables["Products"];
DataRelation relation = thisTable.ParentRelations[0];
GetParentRowForTable(thisTable, relation.RelationName);
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Vea también
|