DataRowCollection.Contains Method (Object)
Gets a value that indicates whether the primary key of any row in the collection contains the specified value.
Assembly: System.Data (in System.Data.dll)
To use the Contains method, the DataTable object to which the DataRowCollection object belongs to must have at least one column designated as a primary key column. See the PrimaryKey property for more information about how to create a primary key column.
Private Sub ColContains() Dim table As DataTable = CType(DataGrid1.DataSource, DataTable) Dim rowCollection As DataRowCollection = table.Rows If rowCollection.Contains(Edit1.Text) Then Label1.Text = "At least one row contains " & Edit1.Text Else Label1.Text = "No row contains the value in its primary key field" End If End Sub
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.