Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
575
DataKeyField is invalid
posted

I'm doing some tests on WebDataGrid in ASP.Net 4.0, and I have this error:

[InvalidOperationException: DataKeyField is invalid] Infragistics.Web.UI.Framework.Data.DataSourceAdapter.Select(DataSourceSelectArguments arguments) +651 Infragistics.Web.UI.Framework.Data.DataSourceObjectView.ExecuteSelect(DataSourceSelectArguments arguments) +73 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74 Infragistics.Web.UI.GridControls.WebDataGrid.DataBind() +974 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.EnsureDataBound() +73 Infragistics.Web.UI.GridControls.WebDataGrid.EnsureDataBound() +186 Infragistics.Web.UI.GridControls.WebDataGrid.CreateChildControls() +75 System.Web.UI.Control.EnsureChildControls() +102 Infragistics.Web.UI.GridControls.WebDataGrid.EnsureChildControls() +129 System.Web.UI.Control.PreRenderRecursiveInternal() +42 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496

 

My WebDataGrid in .aspx page is defined in this way:

 

<ig:WebDataGrid runat="server" ID="grdOrders" Height="400px" Width="600px" EnableViewState="true">

<Behaviors>

<ig:Sorting Enabled="true"></ig:Sorting>

<ig:Filtering Enabled="true"></ig:Filtering>

<ig:ColumnMoving Enabled="true"></ig:ColumnMoving>

<ig:EditingCore Enabled="true">

<Behaviors>

<ig:CellEditing Enabled="true"></ig:CellEditing>

</Behaviors>

</ig:EditingCore>

</Behaviors>

</ig:WebDataGrid>

 

While in the code behind I have only this code:

Dim dtOrders As DataTable

Dim sSql As String = "SELECT OrderYear,OrderType,OrderNumber,CustomerCode FROM Orders WHERE OrderYear=2012"

LoadTable(DBConnection, dtOrders, "Ordini", sSql, True, New String() {"OrderYear", "OrderType", "OrderNumber"})

grdOrders.DataSource = dtOrders

grdOrders.DataKeyFields = "OrderYear,OrderType,OrderNumber"

LoadTable is a function which executes the SQL script, loads data into the DataTable dtOrders and sets the Primary Key with the fields "OrderYear", "OrderType", and "OrderNumber"
The problem is that if I comment the "grdOrders.DataKeyFields..." row, everything works well, but I'm not able to modify any cell in the html page (if I try to do that, at first postback an error saying that I must set DataKeyField is triggered). Instead, if I uncomment that line, the page doesn't show up and the "DataKeyField is invalid" error is triggered.
How can I solve this? Thanks for any help!