DataRow.Table Propriedade

Definição

Obtém o DataTable para o qual essa linha tem um esquema.

public:
 property System::Data::DataTable ^ Table { System::Data::DataTable ^ get(); };
public System.Data.DataTable Table { get; }
member this.Table : System.Data.DataTable
Public ReadOnly Property Table As DataTable

Valor da propriedade

DataTable

O DataTable ao qual essa linha pertence.

Exemplos

O exemplo a seguir usa a Table propriedade para retornar uma referência à coleção de colunas do DataTable.

private void GetTable(DataRow row)
{
    // Get the DataTable of a DataRow
    DataTable table = row.Table;

    // Print the DataType of each column in the table.
    foreach(DataColumn column in table.Columns)
    {
        Console.WriteLine(column.DataType);
    }
}
Private Sub GetTable(ByVal row As DataRow)
   ' Get the DataTable of a DataRow
   Dim table As DataTable = row.Table

   ' Print the DataType of each column in the table.
   Dim column As DataColumn
   For Each column in table.Columns
      Console.WriteLine(column.DataType)
   Next
End Sub

Comentários

A DataRow não pertence necessariamente à coleção de linhas de qualquer tabela. Esse comportamento ocorre quando o DataRow valor foi criado, mas não adicionado ao DataRowCollection. Se a RowState propriedade retornar DataRowState.Detached, a linha não estará em nenhuma coleção.

Aplica-se a

Confira também