Gets a customized view of the table which may include a filtered view, or a cursor position.
[Visual Basic] Public ReadOnly Property DefaultView As DataView [C#] public DataView DefaultView {get;} [C++] public: __property DataView* get_DefaultView(); [JScript] public function get DefaultView() : DataView;
The DataView associated with the DataTable.
The DefaultView property returns a DataView you can use to sort, filter, and search a DataTable.
[Visual Basic, C#] The following example sets a property of the DataTable object's DataView through the DefaultView property. The example also shows the binding of a DataGrid control to a DataTable named "Suppliers" that includes a column named "CompanyName."
[Visual Basic] Private Sub BindDataGrid() Dim myDataTable As New DataTable ' Insert code to populate a DataTable with data. ' Bind DataGrid to DataTable DataGrid1.DataSource = myDataTable End Sub Private Sub ChangeRowFilter() Dim gridTable As DataTable = CType(dataGrid1.DataSource, DataTable) ' Set the RowFilter to display a company names that begin with A through I. gridTable.DefaultView.RowFilter = "CompanyName < 'I'" End Sub [C#] private void BindDataGrid(){ DataTable myDataTable = new DataTable(); // Insert code to populate a DataTable with data. // Bind grid to DataTable. dataGrid1.DataSource = myDataTable; } private void ChangeRowFilter(){ DataTable gridTable = (DataTable) dataGrid1.DataSource; // Set the RowFilter to display a company names that begin with A through I.. gridTable.DefaultView.RowFilter = "CompanyName < 'I'"; }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET