This is a migrated thread and some comments may be shown as answers.

manual filter no longer works

2 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 2
Elliott asked on 28 Dec 2011, 10:15 PM
the following code worked fine in 2010 version but throws exceptions in 2011.3.3115.35

protected void cmbShipDate_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
    string filterExpression;
    filterExpression = RemoveFilter("ShipDate");
    rgEditOrder.MasterTableView.FilterExpression = filterExpression;
    if (cmbShipDate.SelectedItem.Text == "All")
        filterExpression = string.Empty;
    else
        filterExpression = "([ShipDate] = '" + cmbShipDate.SelectedItem.Text + "')";
    rgEditOrder.MasterTableView.FilterExpression = AppendFilterExpression(filterExpression);
    rgEditOrder.EditIndexes.Clear();
    ClearOutItemData();
    rgEditOrder.MasterTableView.Rebind();
}
 
private string AppendFilterExpression(string filterExpression)
{
    StringBuilder sb;
    sb = new StringBuilder(rgEditOrder.MasterTableView.FilterExpression);
    if (filterExpression == string.Empty)
        return sb.ToString();
    if (sb.ToString() != string.Empty)
    {
        sb.Append(" AND ");
    }
    sb.Append(filterExpression);
    return sb.ToString();
}

what gives?

2 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 29 Dec 2011, 10:17 AM
Hello Marianne,

What exactly is the exception that you get? Have you tried setting the EnableLinqExpressions property of RadGrid to false? If the exception you get is "Expression expected", this setting should fix it.

The thing is that with the .NET 3.5 build of RadGrid for ASP.NET AJAX and LINQ filter expressions enabled (EnableLinqExpressions = true), the filter expressions set for the grid either internally by its filtering mechanism or manually in code should conform to the LINQ expression syntax instead of the old T-SQL syntax. Only thus they will be evaluated properly by the control.

All the best,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Elliott
Top achievements
Rank 2
answered on 29 Dec 2011, 03:14 PM
Tsvetina - I set EnableLinqEspressions to false and the code worked again
thanks
Tags
Grid
Asked by
Elliott
Top achievements
Rank 2
Answers by
Tsvetina
Telerik team
Elliott
Top achievements
Rank 2
Share this question
or