Binding RadGrid manually

Thread is closed for posting
3 posts, 0 answers
  1. tmlipinski
    tmlipinski avatar
    131 posts
    Member since:
    Dec 2006

    Posted 19 Feb 2009 Link to this post

    Hi,

    I have a very simple RadGrid:
        <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
          GridLines="None" AutoGenerateColumns="true">
        </telerik:RadGrid>
    And some code for binding the grid:
      protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
      {
        IObjectScope scope = ORMObjectScopeProvider.ObjectScope();
        IQueryResult clist = scope.GetOqlQuery("select * from OrderExtent as x").Execute();
        RadGrid1.DataSource = clist;
      }
    It produces the following error message:
    Telerik.OpenAccess.Exceptions.InvalidOperationException: Any operation that will fully resolve the query may not be called once a 'get' operation was performed
    After I insert the instruction:
        int i = clist.Count;
    just before "RadGrid1.DataSource = clist;" it starts to work well.
    Is it a known workaround of a known problem? And this is why there is a similar "unnecessary" code in your demos?

    Regards
    Tomasz
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 23 Feb 2009 Link to this post

    Hello tmlipinski,
    this is caused by the ForwardsOnly property of IQuery which is set by default to true. You need to set it to false and everything will work out fine.
    IQuery query = scope.GetOqlQuery("select * from OrderExtent as x"); 
                query.ForwardsOnly = false
                IQueryResult clist = scope.GetOqlQuery(query).Execute(); 
                RadGrid1.DataSource = clist; 


    Best wishes,
    PetarP
    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.
  3. tmlipinski
    tmlipinski avatar
    131 posts
    Member since:
    Dec 2006

    Posted 23 Feb 2009 Link to this post

    OK, it works. Thanks.

    Regards
    Tomasz
Back to Top