Finds and returns a DataRow with the specified value in the specified column.
[Visual Basic] Overloads Protected Function FindRow( _ ByVal column As DataColumn, _ ByVal value As Object _ ) As DataRow [C#] protected DataRow FindRow( DataColumn column, object value ); [C++] protected: DataRow* FindRow( DataColumn* column, Object* value ); [JScript] protected function FindRow( column : DataColumn, value : Object ) : DataRow;
A DataRow whose column values match those specified in the method.
You can also use Select method to find a specific row in the DataTable. Furthermore, the Find and Contains methods of the RowsCollection also return specific rows or values in rows.
The following example uses the FindRows method to return a DataRow containing the specified value.
[Visual Basic]
Private Sub FindThisRow() Dim findInThisCol As DataColumn Dim findThisVal As Object Dim foundRow As DataRow Dim t As DataTable ' Use the DataTable of a DataGrid control. t = DataGrid1.DataGridTable.DataTable ' Get two columns from the table. findInThisCol = t.Columns("SupplierID") ' Set the value to find. findThisVal = 25 foundRow = t.FindRows(findInThisCol, findThisVal) Console.WriteLine(foundRow(1)) End Sub
DataTable Class | DataTable Members | System.Data Namespace | DataTable.FindRow Overload List | DataRow | Contains | Find