When binding a grid using the NeedDataSource event, check the RadGrid.MasterTableView.FilterExpression property in the NeedDataSource event handler. This string represents the current filter function in the same way as the DataView.Filter property (that is, it is the text of a WHERE clause for filtering items).

note

If you want to customize filtering using your own custom statements, clear the FilterExpression string (to prevent the default filtering) and bind the grid to a filtered data set.

The following example shows how to access the filter information in the ItemCommand event handler. It saves this information to a set of messages that can be displayed (by the grid's DataBound event handler) to provide feedback about the current filter function:

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.

note

From Q2 2015 version of UI for ASP.NET we introduce a new method on the GridTableView object called GetEntitySqlFilterExpression. The method allows you to get the filter expression in the Entity SQL syntax. However you still need to enable the EnableLinqExpressions property in order to use this method. Otherwise you will receive an exception. The code snippet below demonstrates how to use the method.

The value of the FilterExpression for the grid is a string, including vital information concerning the field (column) which needs to be filtered, along with the value entered by the end user in the filter text box, and the filter option chosen. Internally, the filter expression is created in accordance with the T-SQL syntax (in case we are using the .NET 2.0 built of the control), or follow the newer LINQ expression syntax (when using the .NET 3.5 version).

In most cases the programmer does not need to worry about these details, since the filtering is automatically handled by RadGrid. In some scenarios, however, it is useful to have a better knowledge on how these expressions are constructed. This is the case, for example, when the grid needs to be filtered initially, or when a more complex, custom filter expression should be constructed.

The following table shows the representation of the grid FilterExpression for each filter function when the filter value type is string or numeric. To make it practical, it assumes that we are filtering a string column named CustomerID by a value of 'ALFKI' and a column of a numeric type, called OrderID by a value of '10248' accordingly.

note

In some of the expressions additional parameters are used. For example in this filter function: @"(it[""""])= {numeric value}"; the particular DataType is Int32:

Give article feedback

Tell us how we can improve this article

Code samples are inaccurate/outdated.
I expected to find other/more information.
There are typos/broken links/broken page elements.
Content is inaccurate/outdated.
Other
By checking this box you consent to Progress contacting you by email about your response on this page.