- Run the attached example.
- Create and save a new Employee.
- Create and save a new Team.
- Click Link in the Team.Employees ListView.
- Select an Employee record. The exception will be thrown:
Type: MissingPrimaryKeyException
Message: A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure the field name is spelled correctly. Pay attention to the character case. For detailed information, please refer to the http://www.devexpress.com/kbid=KA18689 article.
Data: 0 entries
Stack trace:
at DevExpress.Web.Data.WebDataProxy.CheckKeyFieldName()
at DevExpress.Web.Data.WebDataProxy.GetKeyValueCore(Int32 index, GetKeyValueCallback getKeyValue)
at DevExpress.Web.Data.WebDataProxy.GetRowKeyValue(Int32 visibleIndex)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridListEditor.SetControlSelectedObjects(IList`1 objects)
at DevExpress.ExpressApp.Web.Editors.ComplexWebListEditor.SetTemporarySelectedObject(Object value)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridViewContextMenu.SelectObject(String objectId)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridViewContextMenu.ProcessCommand(String args)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridViewContextMenu.ProcessCustomCallback(String parameters)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridViewContextMenu.DevExpress.ExpressApp.Web.Templates.IXafCallbackHandler.ProcessAction(String parameter)
at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.ProcessAction(String parameter)
at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.callbackControl_Callback(Object source, CallbackEventArgs e)
at DevExpress.Web.ASPxCallback.ASPxCallback.OnCallback(CallbackEventArgs e)
at DevExpress.Web.ASPxCallback.ASPxCallback.RaiseCallbackEvent(String eventArgument)
at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent(String eventArgument)
InnerException is null
DC - MissingPrimaryKeyException is thrown when the shared part's ListView is displayed in Server Mode in Web
Answers approved by DevExpress Support
We have researched this issue and concluded that it cannot be fixed in the current Domain Components state. It is required to introduce significant changes in the data sources used to display domain components to support this functionality. We will unlikely do this in the near future.
Please turn off Server Mode in list views that display shared parts. Here is an example of how to do this dynamically in code:
C#public sealed partial class MyWebModule : ModuleBase {
...
public override void AddGeneratorUpdaters(ModelNodesGeneratorUpdaters updaters) {
base.AddGeneratorUpdaters(updaters);
updaters.Add(new MyViewsGeneratorUpdater());
}
}
public class MyViewsGeneratorUpdater : ModelNodesGeneratorUpdater<ModelViewsNodesGenerator> {
public override void UpdateNode(ModelNode node) {
foreach (IModelView view in (IModelViews)node) {
if (view is IModelListView) {
ITypeInfo typeInfo = ((IModelListView)view).ModelClass.TypeInfo;
if (typeInfo.IsPersistent && typeInfo.IsInterface) {
XPClassInfo classInfo = XpoTypesInfoHelper.GetXpoTypeInfoSource().GetEntityClassInfo(typeInfo.Type);
if (classInfo != null && classInfo.KeyProperty == null) {
((IModelListView)view).UseServerMode = false;
}
}
}
}
}
}
I have same problem with Denis Sikic when i validate object on the detail view, popup appears and getting below error…
Using V15.2.7
Type: MissingPrimaryKeyException
Message: A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure the field name is spelled correctly. Pay attention to the character case. For detailed information, please refer to the http://www.devexpress.com/kbid=KA18689 article.
You above workarround solution doent work for me, i have no idea why happens this :/
Hi guys,
If you're using XAF and Validation Module,
You sould not enable below features for the context validation list views otherwise you will face with above error…
C#if (View.Id != "ContextValidationResult_ListView")
{
gridView.SettingsBehavior.AllowFocusedRow = true;
gridView.SettingsBehavior.AllowSelectByRowClick = false;
gridView.SettingsBehavior.EnableRowHotTrack = true;
}
Fyi / BR
Mert Eşsiz
Thank you for informing us of your progress. I am happy to hear that you have found a solution. Please do not hesitate to contact us if you need any assistance in the future.