Tab

ASPxFilterControlBase.GetFilterExpressionForAccess() Method

Returns the filter expression for a MS Access database.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

Declaration

public string GetFilterExpressionForAccess()
Public Function GetFilterExpressionForAccess As String

Returns

Type Description
String

A string value that represents the filter expression.

Remarks

Use the filter expression returned by the GetFilterExpressionForAccess function to filter a MS Access data source by adjusting the data source's SelectCommand property value (see the code example below). Alternatively, you can call the ASPxFilterControlBase.GetFilterExpressionForDataSet function, to obtain the filter expression and apply it via the data source control's FilterExpression property.

Examples

The following section of the Data Source Specific Filter Expression online demo illustrates how to obtain the filter expression for a MS Access database via the ASPxFilterControlBase.GetFilterExpressionForAccess method, and apply it via the data source's SelectCommand property.

protected void ASPxDataView1_CustomCallback(object sender, CallbackEventArgsBase e) {
    UpdateDataViewFilterExpression();
}

protected void ASPxFilterControl1_CustomJSProperties(object sender, CustomJSPropertiesEventArgs e) {
    e.Properties["cpFilterExpression"] = ASPxFilterControl1.GetFilterExpressionForAccess();
}

protected void UpdateDataSourceFilterExpression() {
    if (ASPxFilterControl1.IsFilterExpressionValid()) {
        string filterExpression = ASPxFilterControl1.GetFilterExpressionForAccess();
        ASPxLabel1.Text = filterExpression;
        if (!AccessDataSource1.SelectCommand.Contains(filterExpression))
            AccessDataSource1.SelectCommand = string.Format("{0} WHERE {1}", AccessDataSource1.SelectCommand, filterExpression);
    }
    else
        ASPxLabel1.Text = "Filter expression is not valid";
    if(string.IsNullOrEmpty(ASPxLabel1.Text))
        ASPxLabel1.Text = "Filter expression is empty";
}
See Also