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

OpenAccessDataSource: "No oid instance given"

1 Answer 80 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.
Paul Dhingra
Top achievements
Rank 1
Paul Dhingra asked on 27 May 2010, 08:38 PM
I'm new to OpenAccess, but seeing as SP1 is out, I figured I'd give it a try.  In my little experiment, I took a working page that uses EF4 and EntityDataSource controls to populate a hierarchical RadGrid - the following code works fine:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="categories.aspx.vb" Inherits="LE4.categories" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
</head> 
<body> 
    <form id="form1" runat="server">  
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">  
        </telerik:RadScriptManager> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        </telerik:RadAjaxManager> 
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"   
            DataSourceID="edsCategories" GridLines="None" Skin="WebBlue" AutoGenerateDeleteColumn="True"   
            AutoGenerateEditColumn="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"   
            AllowAutomaticUpdates="True">  
            <MasterTableView DataKeyNames="CategoryID" DataSourceID="edsCategories" CommandItemDisplay="Top" 
                        EditMode="InPlace">  
                <DetailTables> 
                    <telerik:GridTableView DataKeyNames="SubCategoryID, CategoryID" DataSourceID="edsSubCategories" 
                        CommandItemDisplay="Top" EditMode="InPlace" AllowAutomaticDeletes="true" 
                        AllowAutomaticInserts="true" AllowAutomaticUpdates="true">  
                        <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="CategoryID" MasterKeyField="CategoryID" /> 
                        </ParentTableRelation> 
                        <RowIndicatorColumn> 
                            <HeaderStyle Width="20px"></HeaderStyle> 
                        </RowIndicatorColumn> 
                        <ExpandCollapseColumn> 
                            <HeaderStyle Width="20px"></HeaderStyle> 
                        </ExpandCollapseColumn> 
                        <Columns> 
                            <telerik:GridBoundColumn DataField="Name" HeaderText="SubCategory"   
                                SortExpression="Name" UniqueName="Name">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="DisplayOrder" DataType="System.Int32"   
                                HeaderText="DisplayOrder" SortExpression="DisplayOrder"   
                                UniqueName="DisplayOrder">  
                            </telerik:GridBoundColumn> 
                        </Columns>                          
                    </telerik:GridTableView> 
                </DetailTables> 
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name"   
                        SortExpression="Name" UniqueName="Name">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="DisplayOrder" DataType="System.Int32"   
                        HeaderText="DisplayOrder" SortExpression="DisplayOrder"   
                        UniqueName="DisplayOrder">  
                    </telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
        <asp:EntityDataSource ID="edsCategories" runat="server"   
            ConnectionString="name=LEEntities"   
            DefaultContainerName="LEEntities" EnableDelete="True"   
            EnableFlattening="False" EnableInsert="True" EnableUpdate="True"   
            EntitySetName="Categories" OrderBy="it.DisplayOrder">  
        </asp:EntityDataSource> 
        <asp:EntityDataSource ID="edsSubCategories" runat="server" 
            ConnectionString="name=LEEntities"   
            DefaultContainerName="LEEntities" EnableDelete="True"   
            EnableFlattening="False" EnableInsert="True" EnableUpdate="True"   
            EntitySetName="SubCategories" OrderBy="it.DisplayOrder" 
            AutoGenerateWhereClause="True">  
            <WhereParameters> 
                <asp:SessionParameter Name="CategoryID" Type="Int32" /> 
            </WhereParameters> 
        </asp:EntityDataSource> 
    </form> 
</body> 
</html> 
 

Simple, and works well.  So I've been dying to try out OpenAccess as EF is causing me some issues in some other areas, so I took my test page and changed the data source controls to OpenAccessDataSource controls:

<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="LE4OA._Default" %> 
 
<%@ Register assembly="Telerik.OpenAccess.Web" namespace="Telerik.OpenAccess" tagprefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
        <Scripts> 
            <%--Needed for JavaScript IntelliSense in VS2010--%> 
            <%--For VS2008 replace RadScriptManager with ScriptManager--%> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> 
        </Scripts> 
    </telerik:RadScriptManager> 
    <script type="text/javascript">  
        //Put your JavaScript code here.  
    </script> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
    </telerik:RadAjaxManager> 
   
    <telerik:RadSkinManager ID="RadSkinManager1" Runat="server" Skin="WebBlue">  
    </telerik:RadSkinManager> 
    <div> 
 
    </div> 
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"   
            DataSourceID="dsCategories" GridLines="None" Skin="WebBlue" AutoGenerateDeleteColumn="True"   
            AutoGenerateEditColumn="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"   
            AllowAutomaticUpdates="True">  
            <MasterTableView DataKeyNames="CategoryID" DataSourceID="dsCategories" CommandItemDisplay="Top" 
                        EditMode="InPlace">  
                <DetailTables> 
                    <telerik:GridTableView DataKeyNames="SubCategoryID, CategoryID" DataSourceID="dsSubCategories" 
                        CommandItemDisplay="Top" EditMode="InPlace" AllowAutomaticDeletes="true" 
                        AllowAutomaticInserts="true" AllowAutomaticUpdates="true">  
                        <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="CategoryID" MasterKeyField="CategoryID" /> 
                        </ParentTableRelation> 
                        <RowIndicatorColumn> 
                            <HeaderStyle Width="20px"></HeaderStyle> 
                        </RowIndicatorColumn> 
                        <ExpandCollapseColumn> 
                            <HeaderStyle Width="20px"></HeaderStyle> 
                        </ExpandCollapseColumn> 
                        <Columns> 
                            <telerik:GridBoundColumn DataField="Name" HeaderText="SubCategory"   
                                SortExpression="Name" UniqueName="Name">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="DisplayOrder" DataType="System.Int32"   
                                HeaderText="DisplayOrder" SortExpression="DisplayOrder"   
                                UniqueName="DisplayOrder">  
                            </telerik:GridBoundColumn> 
                        </Columns>                          
                    </telerik:GridTableView> 
                </DetailTables> 
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name"   
                        SortExpression="Name" UniqueName="Name">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="DisplayOrder" DataType="System.Int32"   
                        HeaderText="DisplayOrder" SortExpression="DisplayOrder"   
                        UniqueName="DisplayOrder">  
                    </telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
    <telerik:OpenAccessDataSource ID="dsCategories" runat="server"   
        ObjectContextProvider="LE4OA.LEEntityDiagrams, LE4OA"   
        TypeName="LE4OA.Category" 
        OrderBy="DisplayOrder" EnableDelete="true" EnableInsert="true" EnableUpdate="true">  
    </telerik:OpenAccessDataSource> 
    <telerik:OpenAccessDataSource ID="dsSubCategories" runat="server"   
        ObjectContextProvider="LE4OA.LEEntityDiagrams, LE4OA"   
        TypeName="LE4OA.SubCategory" 
        OrderBy="DisplayOrder" AutoGenerateWhereClause="true">  
        <WhereParameters> 
            <asp:SessionParameter Name="CategoryID" Type="Int32" /> 
        </WhereParameters> 
    </telerik:OpenAccessDataSource>      
    </form> 
</body> 
</html> 
 

It seems to me that this should work, and when I run it the initial load (of the unexpanded parent table) works fine.  When I expand a section, I get an error:

Server Error in '/' Application.  
--------------------------------------------------------------------------------  
 
No oid instance given.  
Parameter name: oid   
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
 
Exception Details: System.ArgumentNullException: No oid instance given.  
Parameter name: oid  
 
Source Error:   
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.    
 
Stack Trace:   
 
 
[ArgumentNullException: No oid instance given.  
Parameter name: oid]  
   Telerik.OpenAccess.OIDHelper.ToString(IObjectId oid) +155  
   Telerik.OpenAccess.RT.DataSource.OpenAccessDataSourceView.StoreValuesInViewState(IQueryResult result, IObjectScope scope) +751  
   Telerik.OpenAccess.RT.DataSource.OpenAccessDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1386  
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21  
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143  
   Telerik.Web.UI.GridTableView.PerformSelect() +38  
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74  
   Telerik.Web.UI.GridTableView.DataBind() +364  
   Telerik.Web.UI.GridDataItem.OnExpand() +452  
   Telerik.Web.UI.GridItem.set_Expanded(Boolean value) +141  
   Telerik.Web.UI.GridExpandCommandEventArgs.ExecuteCommand(Object source) +84  
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +200  
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37  
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +170  
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37  
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125  
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167  
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10  
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13  
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563  
 
   
 
 
--------------------------------------------------------------------------------  
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1  

Any clues?  I know SP1 is a fresh release, but I'm using VS2010 so this was the only way to go.  I'm hoping to use declarative datasource controls for many of the simpler pages in this project, and only go into programmatic access for a few more complex situations.  But perhaps the OpenAccessDataSource control should be skipped entirely?

Or (I hope), I'm just missing something simple due to not really knowing anything about OA yet?

Paul.

1 Answer, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 28 May 2010, 06:04 PM
Hi Paul Dhingra,

 Working with OpenAccessDataSource and Hierarchical RadGrid is possible and I recommend the following KB article as a reference for all interested in implementing such scenario.

Sincerely yours,
Zoran
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Paul Dhingra
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Share this question
or