Problem with FilterExpression in RadGrid

2 posts, 0 answers
  1. Teija
    Teija avatar
    23 posts
    Member since:
    Oct 2008

    Posted 27 May 2010 Link to this post


    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" /> 

  2. Nikolay Rusev
    Nikolay Rusev avatar
    2287 posts

    Posted 28 May 2010 Link to this post

    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.
Back to Top