System.Data Namespace
Represents a collection of rows for a DataTable.
The DataRowCollection is a major component of the DataTable class, and is accessed via the DataTable.Rows property.
While the DataColumnCollection defines the schema of the table, the DataRowCollection contains the actual data for the table, where each DataRow in the DataRowCollection represents a single row.
You can call the Add and Remove methods to insert and delete DataRow objects from the DataRowCollection. You can also call the Find method to search for DataRow objects that contain specific values in primary key columns, and the Contains method to search character-based data for single words or phrases.
The following examples demonstrate using the Rows property to print the values of each column in each row of a table.
Private void RowsDemo ( DataTable myTable ) {
foreach ( DataRow myRow in myTable.Rows ) {
foreach ( DataColumn myCol in myTable.Columns ) {
Response.Write ( myRow [ myCol ] );
}
}
}
Private Sub RowsDemo ( ByVal myTable As DataTable )
Dim myRow As DataRow, myColumn As DataColumn
For Each myRow in myTable.Rows
For Each myColumn In myTable.Columns
Response.Write ( myRow ( myColumn ) )
Next
Next
End Sub |
|
C# |
VB |
DataColumnCollection DataRow DataTable Rows