DetailsView.CurrentMode Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the current data-entry mode of the DetailsView control.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[<BrowsableAttribute(false)>]
member CurrentMode : DetailsViewMode with get

Property Value

Type: System.Web.UI.WebControls.DetailsViewMode

One of the DetailsViewMode values.

Use the CurrentMode property to determine whether the DetailsView control is in edit, insert, or read-only mode. The following table lists the different mode values.

Mode

Description

DetailsViewMode.Edit

The DetailsView control is in edit mode, which allows the user to update the values of a record.

DetailsViewMode.Insert

The DetailsView control is in insert mode, which allows the user to add a new record to the data source.

DetailsViewMode.ReadOnly

The DetailsView control is in read-only mode, which is the normal display mode.

This value is normally set automatically by the DetailsView control by when the New, Update, Insert, Delete, or Cancel command button is clicked. You can also programmatically change the mode by using the ChangeMode method.

When the DetailsView control changes modes, the events in the following table are raised. This allows you to create a custom event handler that performs a routine when the event occurs.

Event

Description

ModeChanged

Occurs when a command button that changes the mode of the DetailsView control is clicked, but after the mode changes.

ModeChanging

Occurs when a command button that changes the mode of the DetailsView control is clicked, but before the mode changes.

The following code example demonstrates how to use the CurrentMode property to determine whether the DetailsView control is in edit, insert, or read-only mode. If the user attempts to navigate to a different record while the DetailsView control is in edit mode, the paging operation is canceled.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: