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

Binding RadGrid manually

2 Answers 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
tmlipinski
Top achievements
Rank 1
tmlipinski asked on 19 Feb 2009, 03:54 PM
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 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 23 Feb 2009, 03:38 PM
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.
0
tmlipinski
Top achievements
Rank 1
answered on 23 Feb 2009, 04:00 PM
OK, it works. Thanks.

Regards
Tomasz
Tags
General Discussions
Asked by
tmlipinski
Top achievements
Rank 1
Answers by
PetarP
Telerik team
tmlipinski
Top achievements
Rank 1
Share this question
or