System.Data.DataRowCollection.Contains Method

Gets a value that indicates whether the primary key of any row in the collection contains the specified value.

Syntax

public bool Contains (object key)

Parameters

key
The value of the primary key to test for.

Returns

true if the collection contains a System.Data.DataRow with the specified primary key value; otherwise, false.

Remarks

To use the DataRowCollection.Contains(object) method, the System.Data.DataTable object to which the System.Data.DataRowCollection object belongs to must have at least one column designated as a primary key column. See the DataTable.PrimaryKey property for more information about how to create a primary key column.

As soon as you have determined that a row contains the specified value, you can use the DataRowCollection.Find(object) method to return the specific System.Data.DataRow object that has the value.

Requirements

Namespace: System.Data
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0