Working with DataView Objects in Code

The DataView class offers functionality similar to that of the DataTable class’s Select method. Let’s take a closer look at this functionality and compare it to the Select method as we go.

Creating DataView Objects

To use a DataView object to view data in a DataTable, you must associate it with a DataTable object. You can specify the DataTable that the DataView will use in one of two ways: by setting the DataView object’s Table property or by using the DataView’s constructor. The following code snippets are equivalent:

Visual Basic

Dim tbl As New DataTable("TableName") Dim vue As DataView 'Create the DataView and associate it with the DataTable vue = New DataView() vue.Table = tbl 'Perform both operations through ...

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.