System.Web.UI.WebControls Namespace ButtonField Class
.NET Framework version 2.0
Sets or retrieves the command to perform when a button in the ButtonField is clicked.
Inline |
<asp:buttonfield commandname = strValue ... > |
Script |
ButtonField.CommandName = strValue |
strValue |
String specifying the name of the command to perform when a button in the ButtonField is clicked. |
The property is read/write with no default value.
Use the CommandName property to specify or determine the command associated with a button control in a ButtonField.
You can set the CommandName property to any valid string that identifies the command to perform when a button is clicked. You can then programmatically determine the command name from the CommandEventArgs of the parent data-bound control and perform the command appropriately.
NOTE: The GridView control raises the RowCommand event, while the DetailsView control raises the ItemCommand event.
The following example demonstrates how to use the CommandName property to associate a command name with a button. The command name of the clicked button is then programmatically determined in the RowCommand event handler of the GridView control, and the appropriate action is performed.
ButtonField Members Adding Button Fields to a GridView Control