I am looking for an example how to use the FilterExpression when bound to a WCF service using Linq to perform an EqualTo compare. When the form loads, I would like to filter the grid based on a session variable. The following is the code I am using to set the FilterExpression, but I receive and error Expression of type 'Boolean' expected. I have reviewed the following demo but I am not sure how to modify the FilterExpression . Any suggestions?
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| { |
| RadGridProvider.MasterTableView.FilterExpression = @"it""[[StoreID]"" = 2"; |
| GridColumn column = RadGridProvider.MasterTableView.GetColumnSafe("StoreID"); |
| column.CurrentFilterFunction = GridKnownFunction.EqualTo; |
| column.CurrentFilterValue = "2"; |
| RadGridProvider.MasterTableView.Rebind(); |
| } |
| } |
| <telerik:RadGrid runat="server" ID="RadGridProvider" AllowPaging="true" AllowSorting="true" |
| AllowFilteringByColumn="true" EnableLinqExpressions="true" > |
| <MasterTableView DataKeyNames="ProviderID" ClientDataKeyNames="ProviderID"> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <Columns> |
| <telerik:GridBoundColumn DataField="StoreID" HeaderText="Store ID" |
| DataType="System.Int32"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ProviderID" HeaderText="Provider ID" |
| DataType="System.Int32"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Firstname" HeaderText="First Name" |
| DataType="System.String"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <PagerStyle Mode="NumericPages" /> |
| </MasterTableView> |
| <ClientSettings> |
| <DataBinding SelectMethod="GetProviderDataAndCount" Location="Service.svc" |
| SortParameterType="Linq" FilterParameterType="Linq"> |
| </DataBinding> |
| <ClientEvents OnRowSelected="RadGridProvider_RowSelected" OnDataBound="RadGridProvider_DataBound"/> |
| <Selecting AllowRowSelect="true" /> |
| </ClientSettings> |
| </telerik:RadGrid> |