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

Problem with FilterExpression in RadGrid

1 Answer 127 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Teija asked on 27 May 2010, 10:50 PM

Can somebody explain for me how the FilterExpression works?

Im trying to get a simple example to work as I want it to do.

In the example I first used a FilterExpression on the SQLDataSource. First taken from a dropdownlist and then explicitly as "Login_Name='Patrik'". In both cases the filtering is working fine.

Then Im trying to do the same with the RadGrids MasterTableViews FilterExpression but it doesnt seem to work the same. Or Im not getting the syntax. How would I write the FilterExpression to do the same for me as in the SQLDataSource?

And secondly how could I get the FilterExpression to take the selection in the DropDownList?


Here is my code: 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
<html xmlns="" > 
    <head id="Head1" runat="server"
    <title>ASP.NET Example</title> 
        <form id="form1" runat="server"
            <telerik:RadScriptManager runat="server"/> 
                <asp:ListItem Selected="True">Roland</asp:ListItem> 
                SelectCommand="SELECT * FROM Sys_Users"
<%--                FilterExpression="Login_Name='Patrik'"
                    <asp:ControlParameter Name="Title" ControlId="DropDownList1" PropertyName="SelectedValue"/> 
--%>            </asp:SqlDataSource> 
                <MasterTableView FilterExpression="([Login_Name]='Patrik')"
                        <telerik:GridBoundColumn Visible="False" DataField="RecID" /> 
                        <telerik:GridBoundColumn HeaderText="First Name" DataField="F_Name" /> 
                        <telerik:GridBoundColumn HeaderText="Last Name" DataField="L_Name" /> 
                        <telerik:GridBoundColumn HeaderText="Login" DataField="Login_Name" /> 

1 Answer, 1 is accepted

Sort by
Nikolay Rusev
Telerik team
answered on 28 May 2010, 08:25 AM
Hello Mathias,

If you are using .net 3.5/4.0 version of RadGrid filter expressions are in different format. RadGrid internally use Dynamic LINQ in order to perform filtering. The format of the expression depends on what is the source that will be filtered.

In case of SqlDataSource format is as follow: it["FieldName"] = "Value". Thus the expressions like: Login_Name='Patrik' should look as follow: it["Login_Name"] = "Patrik".

Of course you can set EnableLinqExpressions to false of RadGrid and then use sql like expressions - same as for SqlDataSource.

the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Asked by
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question