Getting the following error when doing a databind on a webdatagrid
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
System.InvalidOperationException was caught
Message=DataKeyField is invalid
Source=Infragistics4.Web.v11.2
StackTrace:
at Infragistics.Web.UI.Framework.Data.DataSourceAdapter.Select(DataSourceSelectArguments arguments)
at Infragistics.Web.UI.Framework.Data.DataSourceObjectView.ExecuteSelect(DataSourceSelectArguments arguments)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at Infragistics.Web.UI.GridControls.WebDataGrid.DataBind()
at FedSelectWeb.Risk_Terms.LoadListData() in C:\Projects\FedSelect\FedSelectWeb\FedSelectWeb\Settings\sfrtblRiskTerms.aspx.vb:line 131
InnerException:
Private Sub LoadListData() Try Dim sString As String = Nothing MySession.RiskTermsList = GetRiskTermsList(sString) gGrid.ClearDataSource() gGrid.DataSource = MySession.RiskTermsList gGrid.DataBind() Dim selectedRows As SelectedRowCollection = gGrid.Behaviors.Selection.SelectedRows selectedRows.Add(gGrid.Rows(0)) RecordCount(1, RiskTermsList.Count) Catch ex As Exception End Try End SubThe RiskTermsList is a collection that contains 2 fields, a string and a integer.The string field has been assigned as the datakeyfield.I have other grids with strings as keyfields..any ideas?
I figured it out.
The Key fields must match the case of the database field.
Hello Daryl007,
Thank you for posting in our forum.
Could you send a code snippet of how you define your collection?
By default the grid should have no problem in accepting a string key. The problem may be in the definition of this collection.
If possible provide an isolated sample that reproduces the issue. That would be very helpful in determining what’s causing the issue.
I’m looking forward to your reply.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support