How to: Display a Detail View Directly in Edit Mode in ASP.NET Applications How to: Show Details view in an ASP.NET application directly in edit mode

In ASP.NET applications, when clicking a record in a List View, a Detail View is displayed in view mode. However, the SwitchToEditMode Action is available, and you can use it to reload the Detail View in edit mode. This is the default behavior. In individual scenarios, you may need to invoke a Detail View directly in edit mode. This topic demonstrates how to omit the display in view mode for a particular object type.

In an ASP.NET application, when you click the record list view, displays the detail view in view mode. However, the "switch to edit mode" is available, you can use it to edit mode, reload the details view. This is the default behavior. In the individual program, you may need to call the "Detailed View" directly in edit mode. This topic demonstrates how to display the omission of a specific object type view mode.

 

To set a Detail View's display mode, use the DetailView.ViewEditMode property. To change this property value, implement a View Controller and override the OnActivated method.

To set a detailed view display mode, use the "Detail View .ViewEditMode" attribute. To change the value of this property, implement the view controller and override OnAndonon method.

using DevExpress.ExpressApp.Editors;
//...
public class SwitchToEditModeModificationsController : ViewController<DetailView> {
    protected override void OnActivated() {
        base.OnActivated();
        if (View.ViewEditMode == ViewEditMode.View) {
            View.ViewEditMode = ViewEditMode.Edit;
            ObjectSpace.SetModified(null);
        }
    }
}

 

To accomplish the implemented code when the current View represents an object of a particular type, set the ViewController.TargetObjectType property to this type in the View Controller's constructor. As an example, assume that the Controller is intended for Person type objects.

To complete the implementation of the code in the current view represents a particular type of object, attribute set to the constructor ViewController.TargetObjectType view of this type of controller. For example, assume that controller is adapted to the object type Person.

public SwitchToEditModeModificationsController() {
    TargetObjectType = typeof(Person);
}

 

If you now run the application, you will see that the Person Detail View is always displayed in edit mode.

If you run the application, you will see the "Person Details" view is always displayed in edit mode.

Note Note
The View Controller demonstrated in this topic should be implemented in an ASP.NET module. In Windows Forms applications, Detail Views are always editable.
This topic is demonstrated in the view controller should be implemented in ASP.NET module. In Windows Forms application, view detailed information can always be edited.

Guess you like

Origin www.cnblogs.com/foreachlife/p/How-to-Display-a-Detail-View-Directly-in-Edit-Mode-in-ASP-NET-Applications.html