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

[Solved] Set FilterExpression using Linq Expression

1 Answer 315 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 03 Jul 2009, 11:07 PM

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> 
         


1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 08 Jul 2009, 02:09 PM
Hello Michael,

Please, take a look at the attached sample for a sample implementation of this scenario.

Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or