Using Radgrid filter expression to query collection gives exception 'Expression Expected'

asp.net c# dynamic-linq telerik telerik-grid

Question

I'm attempting to use the filter expression from my radgrid to query a collection. I have the property of on the RadGrid.EnableLinqExpressions = "false"

But I understand the exception.Expression Expected If you apply the code:

results = results.Where(filterExpression);

The filter expression is currently formatted as follows:"(([SCRIPT_AGENT] = 'Jack Davies'))"

How can I deal with this problem?

It operates when I type in the following:

results = results.Where("SCRIPT_AGENT == @0", "Jack Davies")

Exists a method to reuse my existing filter expression or convert it into a format that may be used?

1
1
2/18/2016 12:23:17 PM

Accepted Answer

I made the decision to use a different method and utilize the current data in the rad grid itself when a filter is applied rather than utilizing the filter expression of the rad grid:

        // If there is a filter applied then enter the loop if there isn't then the filter expression will be empty 
        if (!String.IsNullOrEmpty(filterExpression))
        {                
            // Create a new list of strings to hold the sequence ids
            List<string> sequenceIds = new List<string>();

            // For each row in the radgrid...
            foreach (GridDataItem row in rgCallRecordings.Items) // loops through each rows in RadGrid
            {
                // ...Add the sequence id to the list
                sequenceIds.Add(row.GetDataKeyValue("SEQUENCE_ID").ToString());                    
            }
            // Only return results whose sequence ids are in the list
            results = results.Where(a => sequenceIds.Contains(a.SEQUENCE_ID));                
        }    

The mistake was removed and the same outcomes as when utilizing filter expressions were obtained.

0
2/18/2016 4:23:16 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow