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

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

2 Answers 132 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.
Todd
Top achievements
Rank 1
Todd asked on 20 Nov 2015, 01:14 AM

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 Answers, 1 is accepted

Sort by
0
Simeon Simeonov
Telerik team
answered on 24 Nov 2015, 01:18 PM
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.
0
Todd
Top achievements
Rank 1
answered on 24 Nov 2015, 03:33 PM

that was it.  Thanks!

 Todd

Tags
General Discussions
Asked by
Todd
Top achievements
Rank 1
Answers by
Simeon Simeonov
Telerik team
Todd
Top achievements
Rank 1
Share this question
or