An ObjectKey must have at least one key name and value.

3 posts, 0 answers
  1. Todd
    Todd avatar
    2 posts
    Member since:
    Nov 2015

    Posted 19 Nov 2015 Link to this post

    I am experimenting with Data Access and after building my first project based around the Sofia Car Rental example, I get this exception:

     An ObjectKey must have at least one key name and value.

    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: 

    [ArgumentException: An ObjectKey must have at least one key name and value. ] Telerik.OpenAccess.ObjectKey.DeserializeToKeyValuePairs(IEnumerable`1 objectKeyValues, String[]& keyNamesOut, Object[]& keyValuesOut, Boolean allowNull) +575 Telerik.OpenAccess.ObjectKey..ctor(String typeName, IEnumerable`1 objectKeyValues) +97 Telerik.OpenAccess.Web.OpenAccessLinqDataSourceView.GetObjectKeyByObjectKeyParts(IDictionary keys) +392 Telerik.OpenAccess.Web.OpenAccessLinqDataSourceView.GetObjectByKeys(IDictionary keys) +17 Telerik.OpenAccess.Web.OpenAccessLinqDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +137 System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +183 Telerik.Web.UI.GridTableView.PerformDelete(GridEditableItem editedItem, Boolean suppressRebind) +325 Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +2781 Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +162 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +50 Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +117 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3360

     

    Following the Sofia Car Rental example does the exact same thing on deletes or updates.  Any ideas?  using SQL Server 2012.  

     Thanks.

     Todd

  2. Simeon Simeonov
    Admin
    Simeon Simeonov avatar
    24 posts

    Posted 24 Nov 2015 Link to this post

    Hello Todd,
    Thank you for contacting us.

    It seems the issue may be related to the DataKeyNames property of the MasterTableView configuration. In this property you should identify the primary key fields for the items displayed in a Radgrid control. For example if you have a grid in which you want to display the Categories from the Sofia Car Rental example, you should set the DataKeyNames property to "CategoryID" like this:
    <telerik:RadGrid ID="RadGrid1" runat="server"
        DataSourceID="OpenAccessLinqDataSourceCategory"
        AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True"
        AllowAutomaticUpdates="True"
        AutoGenerateDeleteColumn="True"
        AutoGenerateEditColumn="True">
        <MasterTableView
            DataSourceID="OpenAccessLinqDataSourceCategory"
            CommandItemDisplay="TopAndBottom"
            DataKeyNames="CategoryID">
            <RowIndicatorColumn Visible="False">
            </RowIndicatorColumn>
            <ExpandCollapseColumn Created="True">
            </ExpandCollapseColumn>
        </MasterTableView>
    </telerik:RadGrid>

    I hope you find this information helpful.

    Regards,
    Simeon Simeonov
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. DevCraft banner
  4. Todd
    Todd avatar
    2 posts
    Member since:
    Nov 2015

    Posted 24 Nov 2015 in reply to Simeon Simeonov Link to this post

    that was it.  Thanks!

     Todd

Back to Top