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

custom filtering with objectdatasource in .NET 4.0

2 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Datamex
Top achievements
Rank 2
Datamex asked on 17 May 2011, 01:05 PM
Hi,

I want to implement custom filtering in my radGrid, but I don't get it to work right now. What I'm trying to do is the following:

I have radGrid and the datasource of the grid is an objectdatasource. In the selecting event of the objectdatasource i add my filterexpression and sortexpression. In the function in my businesslogics, i have the filterexpression, sortexpression, startindex and maximumrows. The filterexpression is coming to the function properly, but i can't get it to work with my entitymodel. I've tried enableLinqExpression="True" and enableLinqExpression="False" but with both options it doesn't work.This is the code of the function:

 

 

public static IQueryable<vw_TrainingCompanyLocations> GetTrainingCompanyLocations(string filterExpression, string sortExpression, int maximumRows, int startRowIndex)
    {
      KolipeEntities db = new KolipeEntities();
  
      IQueryable<vw_TrainingCompanyLocations> data;
  
      if (!string.IsNullOrEmpty(filterExpression))
        data = db.vw_TrainingCompanyLocations.Where(filterExpression);
      else
        data = db.vw_TrainingCompanyLocations;
  
      return data;
    }
 

 Do you have any idea how to get this to work?

2 Answers, 1 is accepted

Sort by
0
Ben
Top achievements
Rank 1
answered on 17 May 2011, 10:20 PM
I have the same issue.

It seems that 'EnableLinqExpressions' doesn't work right with ObjectDataSource objects.  When I get a filter expression, it's always in SQL format regardless of that property being set to 'true' or 'false'.
0
Tsvetina
Telerik team
answered on 20 May 2011, 10:55 AM
Hello Datamex,

You can take a look at the project attached to the following forum post, which demonstrates how to achieve the desired functionality. I hope it helps.
Filtering with linq through an ObjectDataSource

Greetings,
Tsvetina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Datamex
Top achievements
Rank 2
Answers by
Ben
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or