RadGrid + Entity Framework executes Query 3 times

5 posts, 0 answers
  1. orim
    orim avatar
    29 posts
    Member since:
    Mar 2012

    Posted 20 Dec 2012 Link to this post

    My Environment: VS 2010 SP 1, EF 4/5, Teleri RadControls AJAC Q3 SP1 - 12.3.1205.0

    Protected Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
            Dim d As New Ares4AgsmEntities
            Dim q = From i In d.Computer
                    Select i.SamAccountName, i.SerialNumber
            RadGrid1.DataSource = q
        End Sub
    Bind RadGrid to EF context executes the same query 3 times (see SQL Profiler). I also bind GridView to EF context this executs query 1 time.
    Bind RadGrid to EntityDatasource this executes the query 1 time.
    Whats the problem ? Is this a default behavior ?

  2. Pavlina
    Pavlina avatar
    6069 posts

    Posted 25 Dec 2012 Link to this post


    May I ask you to open a formal support ticket and send us a sample runnable project where the described problem can be observed. We will debug it locally and will advice you further.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
  4. Huy Viet
    Huy Viet avatar
    2 posts
    Member since:
    Oct 2015

    Posted 30 Oct 2015 Link to this post

    I have a similar issue, the SQL profiler show 3 calls with the same query.

    In the ASPX we have a grid:

    <telerik:RadGrid ID="ProjectsGrid" runat="server"
    Height="99%" >

    where in our aspx.cs, the call back is define like this:

    protected Project_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)


    RadGrid grid = sender as RadGrid;
    SqlDataSource sql = new SqlDataSource();


    grid.DataSource = sql;


    Our environment: VS 2013 with the latest version of Telerik.

    Any insight?

  5. Joe
    Joe avatar
    6 posts
    Member since:
    Feb 2015

    Posted 04 Nov 2015 in reply to Huy Viet Link to this post

    I had the same issue. I think it depends on how everything is setup. I know that my MVC app will run all of those things twice. Webform app with RadGrid does it three times. As a temporary measure I copied the data results to a memory cache and pass that back rather than doing more db calls. I think it has something to do with having the db calls in the view itself.
  6. Huy Viet
    Huy Viet avatar
    2 posts
    Member since:
    Oct 2015

    Posted 04 Nov 2015 Link to this post

    Thanks Joseph for the reply, Will investigate copying the data results to a memory cache.

    We have tried to use the EntityDataSource instead, but it wouldn't work (or at least we don't see how) as our SQL Queries have "COLLATE" and also access two DBs in a single query.

    Using an asp:GridView, would be a major redesign, and I'm not sure it has all the fonctionnality of the RadGrid, so we would like to find a solution with the RadGrid, Is-it possible to configure a RadGrid with a SQLDataSource so that it does not query 3 times the DB?

Back to Top
DevCraft R3 2016 release webinar banner