asp.net.ph

DataTable.DefaultView Property

System.Data Namespace   DataTable Class


Returns a customized view of the table which may include a filtered view, or a cursor position.

Syntax


Script [ DataView variable = ] DataTable.DefaultView

Property Value


variable Returns the DataView associated with the DataTable.

The property is read only with no default value.

Remarks

The DefaultView property returns a DataView you can use to sort, filter, and search a DataTable.

Example

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".

Private void DefaultViewDemo ( ) {
   DataTable myDataTable = new DataTable ( );
   // insert code to populate a DataTable with data.

   // bind grid to DataTable.
   myDataGrid.DataSource = myDataTable;
}

private void ChangeRowFilter ( ) {
   DataTable gridTable = ( DataTable ) myDataGrid.DataSource;
   // set the RowFilter to display a company names that begin with A through I..
   gridTable.DefaultView.RowFilter = "CompanyName <= 'I'";
}
  C# VB

See Also

DataTable Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph