This documentation is archived and is not being maintained.

DataView Class

Represents a databindable, customized view of a DataTable for sorting, filtering, searching, editing, and navigation.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

public ref class DataView : public MarshalByValueComponent, IBindingListView, IBindingList, IList, 
	ICollection, IEnumerable, ITypedList, ISupportInitializeNotification, ISupportInitialize
public class DataView extends MarshalByValueComponent implements IBindingListView, IBindingList, 
	IList, ICollection, IEnumerable, ITypedList, ISupportInitializeNotification, 
	ISupportInitialize
public class DataView extends MarshalByValueComponent implements IBindingListView, IBindingList, 
	IList, ICollection, IEnumerable, ITypedList, ISupportInitializeNotification, 
	ISupportInitialize

A major function of the DataView is to allow for data binding on both Windows Forms and Web Forms.

Additionally, a DataView can be customized to present a subset of data from the DataTable. This capability lets you have two controls bound to the same DataTable, but that show different versions of the data. For example, one control might be bound to a DataView that shows all the rows in the table, and a second might be configured to display only the rows that have been deleted from the DataTable. The DataTable also has a DefaultView property. This returns the default DataView for the table. For example, if you want to create a custom view on the table, set the RowFilter on the DataView returned by the DefaultView.

To create a filtered and sorted view of data, set the RowFilter and Sort properties. Then, use the Item property to return a single DataRowView.

You can also add and delete from the set of rows using the AddNew and Delete methods. When you use those methods, the RowStateFilter property can set to specify that only deleted rows or new rows be displayed by the DataView.

The following example creates a single DataTable with one column and five rows. Two DataView objects are created and the RowStateFilter is set on each to show different views of the table data. The values are then printed.

No code example is currently available or this language may not be supported.

This type is safe for multithreaded read operations. You must synchronize any write operations.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: