System.Data Namespace DataRow Class
Returns the DataTable in which this row has a schema.
Script |
[ DataTable variable = ] DataRow.Table |
variable |
The DataTable in which this row belongs. |
The property is read only with no default value.
A DataRow does not necessarily have to belong to any table's collection of rows. This can occur when the DataRow has been created but not added to the DataRowCollection. If the RowState property returns DataRowState.Detached, the row is not in any collection.
The following example uses the Table property to return a reference to the columns collection of the DataTable.
private void GetTable ( DataRow myRow ) {
// get the DataTable of a DataRow
DataTable myTable = myRow.Table;
// print the DataType of each column in the table.
foreach ( DataColumn col in myTable ) {
Response.Write ( col.DataType );
}
}
Private Sub GetTable ( ByVal myRow As DataRow )
' get the DataTable of a DataRow
Dim myTable As DataTable = myRow.Table
' print the DataType of each column in the table.
Dim col As DataColumn
For Each col in myTable
Response.Write ( col.DataType )
Next
End Sub |
|
C# |
VB |
DataRow Members ColumnsCollection DataTable