asp.net.ph

DataRowCollection.Find Method

System.Data Namespace   DataRowCollection Class


Returns a specified DataRow.

Overload List

1. Returns the row specified by the primary key value.

2. Returns the row containing the specified primary key values.


Example

The following example uses the values of an array to find a specific row in a collection of DataRow objects. The method presumes a DataTable exists with three primary key columns. After creating an array of the values, the code uses the Find method with the array to get the particular object desired.

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 FindInMultiPKey ( DataTable myTable ) {
   DataRow foundRow;
   // create an array for the key values to find.
   object [ ] findTheseVals = new object [ 3 ];
   // set the values of the keys to find.
   findTheseVals [ 0 ] = "John";
   findTheseVals [ 1 ] = "Smith";
   findTheseVals [ 2 ] = "5 Main St.";
   foundRow = myTable.Rows.Find ( findTheseVals );
   // display column 1 of the found row.
   if ( foundRow != null )
      Response.Write ( foundRow [ 1 ] );
}
  C# VB

See Also

DataRowCollection Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph