FormViewCommandEventArgs Class
Provides data for the ItemCommand event.
System::EventArgs
System.Web.UI.WebControls::CommandEventArgs
System.Web.UI.WebControls::FormViewCommandEventArgs
Assembly: System.Web (in System.Web.dll)
The FormViewCommandEventArgs type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | FormViewCommandEventArgs | Initializes a new instance of the FormViewCommandEventArgs class. |
| Name | Description | |
|---|---|---|
![]() | CommandArgument | Gets the argument for the command. (Inherited from CommandEventArgs.) |
![]() | CommandName | Gets the name of the command. (Inherited from CommandEventArgs.) |
![]() | CommandSource | Gets the control that raised the event. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The ItemCommand event is raised when a button within the FormView control is clicked. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.
Buttons within a FormView control can also invoke some of the built-in functionality of the control. To perform one of these operations, set the CommandName property of a button to one of the values in the following table.
CommandName value | Description |
|---|---|
"Cancel" | Cancels an edit or insert operation and returns the FormView control to the mode specified by the DefaultMode property. Raises the ModeChanged and ModeChanging events. |
"Delete" | Deletes the current record. Raises the ItemDeleted and ItemDeleting events. |
"Edit" | Puts the FormView control in edit mode. Raises the ModeChanged and ModeChanging events. |
"Insert" | Inserts the current record in the data source. Raises the ItemInserted and ItemInserting events. |
"New" | Puts the FormView control in insert mode. Raises the ModeChanged and ModeChanging events. |
"Page" | Performs a paging operation. Set the CommandArgument property of the button to "First", "Last", "Next", "Prev", or a page number to specify the type of paging operation to perform. Raises the PageIndexChanged and PageIndexChanging events. |
"Update" | Updates the current record in the data source. Raises the ItemUpdated and ItemUpdating events. |
Although the ItemCommand event is raised when a button listed in the previous table is clicked, it is recommended that you use the events listed in the table for the operation.
A FormViewCommandEventArgs object is passed to the event-handling method, which allows you to determine the command name and command argument of the button clicked. To determine the command name and command argument, use the CommandName and CommandArgument properties, respectively. You can also access the button control that raised the event by using the CommandSource property.
For more information about handling events, see Consuming Events.
For a list of initial property values for an instance of the FormViewCommandEventArgs class, see the FormViewCommandEventArgs constructor.
The following example demonstrates how to use the FormViewCommandEventArgs object passed to the event-handling method for the ItemCommand event to determine which button within a FormView control was clicked by the user.
Security Note |
|---|
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



Security Note