Export (0) Print
Expand All

DataView.RowFilter Property

Gets or sets the expression used to filter which rows are viewed in the DataView.

[Visual Basic]
Public Overridable Property RowFilter As String
[C#]
public virtual string RowFilter {get; set;}
[C++]
public: __property virtual String* get_RowFilter();
public: __property virtual void set_RowFilter(String*);
[JScript]
public function get RowFilter() : String;
public function set RowFilter(String);

Property Value

A string that specifies how rows are to be filtered. For more details, see the Remarks below.

Remarks

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 quotes. For example:

"LastName = 'Smith'"

See the DataColumn class's Expression property for more information.

To return only those columns with null values, use the following expression:

"Isnull(Col1,'Null Column') = 'Null Column'"

Example

[Visual Basic, C#, C++] The following example creates a DataView and sets its RowFilter property.

[Visual Basic] 
Private Sub MakeDataView()
   Dim dv As DataView
   dv = New DataView
   With dv
      .Table = DataSet1.Tables("Suppliers")
      .AllowDelete = True
      .AllowEdit = True
      .AllowNew = True
      .RowFilter = "City = 'Berlin'"
      .RowStateFilter = DataViewRowState.ModifiedCurrent
      .Sort = "CompanyName DESC"
   End With
   
   ' Simple bind to a TextBox control
   Text1.DataBindings.Add("Text", dv, "CompanyName")
End Sub

[C#] 
private void MakeDataView() 
{
   DataView dv = new DataView();

   dv.Table = DataSet1.Tables["Suppliers"];
   dv.AllowDelete = true;
   dv.AllowEdit = true;
   dv.AllowNew = true;
   dv.RowFilter = "City = 'Berlin'";
   dv.RowStateFilter = DataViewRowState.ModifiedCurrent;
   dv.Sort = "CompanyName DESC";
   
   // Simple bind to a TextBox control
   Text1.DataBindings.Add("Text", dv, "CompanyName");
}

[C++] 
private:
 void MakeDataView() 
{
    DataView* dv = new DataView();

    dv->Table = DataSet1->Tables->Item[S"Suppliers"];
    dv->AllowDelete = true;
    dv->AllowEdit = true;
    dv->AllowNew = true;
    dv->RowFilter = S"City = 'Berlin'";
    dv->RowStateFilter = DataViewRowState::ModifiedCurrent;
    dv->Sort = S"CompanyName DESC";
    
    // Simple bind to a TextBox control
    Text1->DataBindings->Add(S"Text", dv, S"CompanyName");
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter 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

DataView Class | DataView Members | System.Data Namespace | Expression | Sort

Show:
© 2014 Microsoft