DataView.RowFilter Property
Gets or sets the expression used to filter which rows are viewed in the DataView.
Assembly: System.Data (in System.Data.dll)
To form a RowFilter value, specify the name of a column followed by an operator and a value to filter on. The value must be in quotation marks. For example:
"LastName = 'Smith'"
See the Expression property of the DataColumn class for more information.
To return only those columns with null values, use the following expression:
"Isnull(Col1,'Null Column') = 'Null Column'"
The following example creates a DataView and sets its RowFilter property.
private void MakeDataView() { DataView view = new DataView(); view.Table = DataSet1.Tables["Suppliers"]; view.AllowDelete = true; view.AllowEdit = true; view.AllowNew = true; view.RowFilter = "City = 'Berlin'"; view.RowStateFilter = DataViewRowState.ModifiedCurrent; view.Sort = "CompanyName DESC"; // Simple-bind to a TextBox control Text1.DataBindings.Add("Text", view, "CompanyName"); }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
There are several ways. Set the filter to nothing. Make a new DataView from a DataTable.
But this isn't the place for questions. Please use msdn forms to get answers.
- 10/7/2010
- Luis Forero
- 5/17/2011
- TamusJRoyce