custom filtering with objectdatasource in .NET 4.0

3 posts, 0 answers
  1. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 17 May 2011 Link to this post


    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);
            data = db.vw_TrainingCompanyLocations;
          return data;

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

  2. Ben
    Ben avatar
    3 posts
    Member since:
    Feb 2011

    Posted 17 May 2011 Link to this post

    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'.
  3. DevCraft R3 2016 release webinar banner
  4. Tsvetina
    Tsvetina avatar
    1861 posts

    Posted 20 May 2011 Link to this post

    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

    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.

Back to Top