KB Article T382896
Visible to All Users

Why can a DetailView be not editable or display empty values?

SYMPTOMS
1.  You are creating a new detail form via the XafApplication.CreateDetailView API in a Web application, but it does not allow users to enter any information; e.g., they can't write/select anything into/from lookups. The View controls also look "readonly" or disabled. The same code produces an editable DetailView in WinForms, though.
2.  Same readonly View editors as in the previous point, but the controls do not display any values either + the code does not work in both WinForms and ASP.NET apps.
3.  You are opening a DetailView of an object that was deleted by another user. This way, this behavior is normal and expected as removed data can no longer be edited.

   

SOLUTIONS
1.  Make sure you have set the DetailView.ViewEditMode property to the DevExpress.ExpressApp.Editors.ViewEditMode.Edit value. For example, check the snippet from this KB Article:

C#
... DetailView dv = Application.CreateDetailView(os, obj); dv.ViewEditMode = DevExpress.ExpressApp.Editors.ViewEditMode.Edit;//!!! e.ShowViewParameters.CreatedView = dv; ...

It's a known specificity of the XAF ASP.NET WebForms UI and common Web UI in general that detail forms have two modes: view and edit. There is no such behavior in WinForms, where DetailView.ViewEditMode is always Edit by default.

2.  Make sure you are using the XafApplication.CreateDetailView method overload from this list that accepts the "object obj" parameter and this parameter is actually not null. Otherwise, an empty detail form will be created by default.
Alternatively, you can explicitly set the DetailView.CurrentObject property to a non-empty object value; e.g.:

C#
... DetailView dv = Application.CreateDetailView(objectSpace, "DemoTask_DetailView", true); dv.CurrentObject = objectSpace.CreateObject<DemoTask>(); ...

Use this approach caution when assigning a new object to an existing DetailView, which is already set to Frame and for which Controllers are activated; e.g., when customizing an embedded DetailView as part of a DashboardViewItem. In this case, handling the XafApplication.DetailViewCreating event can be a better choice (learn more…).

IMPORTANT NOTE:
In all cases make sure the resultant value of the View.AllowEdit property as well as of the individual PropertyEditor.AllowEdit property is set to True. If it is false, you can diagnose the reason by following the Determine Why an Action, Controller or Editor is Inactive article.

Search keywords
read-only, disabled, enable, readonly, non-editable, cannot edit, editable, allow data entry, CRUD, grayed

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.