System.Data Namespace DataRowView Class
Sets or retrieves a value of a specified column.
1. Sets or retrieves a value of a specified column given the column name.
2. Sets or retrieves a value of a specified column given the column index.
The following example displays the value in each item of each DataRowView in a DataView.
NOTE: This example uses one of the overloaded versions of the DataRowView.Item ( indexer ) property. For other examples that may be available, see the individual overload topics.
private static void WriteViewRows ( DataView dv ) {
int colCount = dv.Table.Columns.Count;
// iterate through the rows of the DataView.
foreach ( DataRowView drv in dv ) {
// display the value in each item of the DataRowView
for ( int i = 0; i < colCount; i++ ) {
Response.Write ( drv [ ] + "<br>" );
}
Response.Write ( );
}
}
Private Shared Sub WriteViewRows ( dv As DataView )
Dim colCount As Integer = dv.Table.Columns.Count
' iterate through the rows of the DataView.
Dim drv As DataRowView
For Each drv In dv
' display the value in each item of the DataRowView
Dim i As Integer
For i = 0 To colCount
Response.Write ( drv ( i ) & "<br>" )
Next
Response.Write ( )
Next
End Sub |
|
C# |
VB |
DataRowView Members