System.Data Namespace DataView Class
Finds a row in the DataView.
1. Finds a row in the DataView by the specified primary key value.
2. Finds a row in the DataView by the specified primary key values.
The following example uses the Find method to return the index of a row that contains specified values in its primary key columns.
NOTE: This example uses one of the overloaded versions of Find. For other examples that may be available, see the individual overload topics.
private void FindValueInDataView ( DataTable tbl ) {
DataView dv = New DataView ( tbl );
dv.Sort = "Cusomers";
Object [ ] vals ( 1 );
vals [ 0 ] = "John";
vals [ 1 ] = "Smith";
// Find the customer named "John Smith".
int i = dv.Find ( vals );
Response.Write ( dv [ ] );
}
Private Sub FindValueInDataView ( tbl As DataTable )
Dim dv As DataView = New DataView ( tbl )
dv.Sort = "Cusomers"
Dim vals ( 1 ) As Object
vals ( 0 ) = "John"
vals ( 1 ) = "Smith"
' Find the customer named "John Smith".
Dim i As Integer = dv.Find ( vals )
Response.Write ( dv ( i ) )
End Sub |
|
C# |
VB |
DataView Members