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.
What are I doeing vrong?
Anders Pedersen
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;
}
}
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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