Skip to main content
A newer version of this page is available. .
Tab

ASPxGridBase.FilterExpression Property

Gets or sets the filter criterion which is applied to the grid.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.2.dll

Declaration

[DefaultValue("")]
public string FilterExpression { get; set; }

Property Value

Type Default Description
String String.Empty

A String value that specifies the filter criterion.

Remarks

Concept

Examples

The following examples illustrate different scenarios on how to filter the grid data.

  • Filter data by dates.

    DateTime date1 = new DateTime(1995, 1, 1);
    DateTime date2 = new DateTime(1995, 7, 1);
    string filter = String.Format("[OrderDate] > #{0}# And [OrderDate] < #{1}#",
                        date1..ToString("yyyy-MM-dd"), date2..ToString("yyyy-MM-dd"));
    ASPxGridView1.FilterExpression = filter;
    
  • Applying a filter that selects departments whose budget is greater than 100,000 and that are located in Monterey. The filter criteria are displayed within the ASPxGridView’s Title Panel.

    ASPxGridView1.FilterExpression = "[Budget] > 100000  AND [Location] = 'Monterey'";
    ASPxGridView1.SettingsText.Title = ASPxGridView1.FilterExpression;
    

    Result:

    ASPxGridView_FilterExpression

  • Select data rows whose product name starts with “ch”.

    ASPxGridView1.FilterExpression = "StartsWith([ProductName], 'ch')";
    
  • Get field names from the filter expression value.

    int start = -1;
    List<string> fields = new List<string>();
    for (int i = 0; i < ASPxGridView1.FilterExpression.Length; i++) {
        if (ASPxGridView1.FilterExpression[i] == '[')
            start = i;
        if (ASPxGridView1.FilterExpression[i] == ']') {
            fields.Add(ASPxGridView1.FilterExpression.Substring(start + 1, i - start - 1));
            start = -1;
        }
    }
    

Online Demos

The following code snippets (auto-collected from DevExpress Examples) contain references to the FilterExpression property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also