Bug Report B253168
Visible to All Users

DC - MissingPrimaryKeyException is thrown when the shared part's ListView is displayed in Server Mode in Web

created 11 years ago
  1. Run the attached example.
  2. Create and save a new Employee.
  3. Create and save a new Team.
  4. Click Link in the Team.Employees ListView.
  5. 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

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

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; } } } } } }
    Show previous comments (2)

      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

        Anatol (DevExpress) 9 years ago

          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.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.