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">
<ig:CellEditing Enabled="true"></ig:CellEditing>
</Behaviors>
</ig:EditingCore>
</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"
Add-on: I'm using NetAdvantage ASP.NET 2011 Vol. 2 on Visual Studio 2010 and Framework 4.0.
Hi elvandar,
Thank you for posting in the community.
Please refer to the attached sample, in which I used DataTable with composite primary key and WebDataGrid with enabled row updating. I would also suggest that you check the following threads which you might find helpful - http://blogs.infragistics.com/forums/p/41108/230234.aspx, http://blogs.infragistics.com/forums/p/58655/298258.aspx.
Please let me know if this helps.
Thanks for your feedback.
I solved the problem a minute ago. It was the, despite capital letters in the query (like "OrderYear") columns were loaded with all lower letters.
After changing
with
grdOrders.DataKeyFields = "orderyear,ordertype,ordernumber"
everything started working.
Hello elvandar,
I'm glad you solved this.
If you have any other questions, do not hesitate to ask.