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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.