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

Gets a "Expression Expected" error on filtering van RadGrid in codebehind

3 Answers 339 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 10 Nov 2014, 02:26 PM
In this simple example (found here in the forum) for setting the filtering in code behind I get a "Expression Expected"  error.

I have already set the EnableLinqExpression="false" in the grid.

public enum MyEnum
{
    Value1,
    Value2,
    Value3,
    Value4,
    Value5
}
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        if (RadGrid1.MasterTableView.FilterExpression == "")
        {
            RadGrid1.MasterTableView.FilterExpression = "([Value] = '" + MyEnum.Value1 + "')";
        }
        else
        {
            RadGrid1.MasterTableView.FilterExpression = "";
        }
        RadGrid1.Rebind();
    }
 
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("Key");
        table.Columns.Add("Value");
        for (int i = 1; i < 6; i++)
        {
            table.Rows.Add("Key" + i.ToString(), "Value" + i.ToString());
        }
        RadGrid1.DataSource = table;
    }
}

<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <div>
        <h2>Test Grid filtering</h2>
        <telerik:RadButton ID="RadButton1" runat="server" onclick="RadButton1_Click"
            Text="RadButton">
        </telerik:RadButton>
    </div>
    <telerik:RadGrid ID="RadGrid1" runat="server" EnableLinqExpression="false" AllowFilteringByColumn="true"
        onneeddatasource="RadGrid1_NeedDataSource" Width="500px">
    </telerik:RadGrid>
    </form>
</body>
</html>

What are I doeing vrong?

Anders Pedersen

3 Answers, 1 is accepted

Sort by
0
Anders
Top achievements
Rank 1
answered on 10 Nov 2014, 02:28 PM
Sorry for the double post - I thought the first was not accepted.
0
Accepted
Konstantin Dikov
Telerik team
answered on 13 Nov 2014, 08:13 AM
Hello Anders,

The issue that you are experiencing is due to the fact that you have minor mistake within your RadGrid settings, which could be easily missed. The correct name of the property that you need to set to false is "EnableLinqExpressions" and not "EnableLinqExpression". Once you add "s" at the end of your property, everything is working correctly and the filter is applied as expected.


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Anders
Top achievements
Rank 1
answered on 21 Nov 2014, 01:55 PM
Tanks alot.

Anders
Tags
Grid
Asked by
Anders
Top achievements
Rank 1
Answers by
Anders
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or