Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DetailsViewCommandEventArgs Class
Collapse the table of content
Expand the table of content

DetailsViewCommandEventArgs Class

Provides data for the ItemCommand event.


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

type DetailsViewCommandEventArgs =  
        inherit CommandEventArgs 

The DetailsViewCommandEventArgs type exposes the following members.

Public methodDetailsViewCommandEventArgsInitializes a new instance of the DetailsViewCommandEventArgs class.

Public propertyCommandArgumentGets the argument for the command. (Inherited from CommandEventArgs.)
Public propertyCommandNameGets the name of the command. (Inherited from CommandEventArgs.)
Public propertyCommandSourceGets the source of the command.
Public propertyHandledGets or sets a value that indicates whether the control has handled the event.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The DetailsView control raises the ItemCommand event when a button within a ButtonField, CommandField, or TemplateField row field is clicked. This allows you to provide an event handler that performs a custom routine whenever this event occurs.


The DetailsView control also raises other specialized events when certain buttons are clicked (buttons with the CommandName property set to "Delete", "Insert", "Page", or "Update"). When using one of these buttons, you should consider using one of the specialized events provided by the control (such as ItemDeleted or ItemDeleting).

A DetailsViewCommandEventArgs object is passed to the event handler. If the button that raised the event has a command name or command argument value, you can use the DetailsViewCommandEventArgs object to determine these values. To determine the command name and command argument of the button clicked, use the CommandName and CommandArgument properties, respectively. You can also access the DetailsView control that raised the event by using the CommandSource property.

For a list of initial property values for an instance of the DetailsViewCommandEventArgs class, see the DetailsViewCommandEventArgs constructor.

The following code example demonstrates how to use the DetailsViewCommandEventArgs object passed to the event handler for the ItemCommand event to determine the command name of the button clicked by the user. This example uses the single-file coding model.

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

The following code example shows a code-behind coding model version of the previous example. For this example to work, you must copy the code below into the associated code-behind file.

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

The following code example shows the code-behind file for the previous example.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft