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; Property Value
The DataView associated with the DataTable.
Remarks
The DefaultView property returns a DataView you can use to sort, filter, and search a DataTable.
Example
[Visual Basic, C#, 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++]
private:
void BindDataGrid(){
DataTable* myDataTable = new DataTable();
// Insert code to populate a DataTable with data.
// Bind grid to DataTable.
dataGrid1->DataSource = myDataTable;
}
void ChangeRowFilter(){
DataTable* gridTable = dynamic_cast<DataTable*> (dataGrid1->DataSource);
// Set the RowFilter to display a company names that begin with A through I..
gridTable->DefaultView->RowFilter = S"CompanyName < 'I'";
}
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
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
See Also
DataTable Class | DataTable Members | System.Data Namespace