asp.net.ph

ButtonField.CommandName Property

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.

Syntax


Inline <asp:buttonfield commandname = strValue ... >
Script ButtonField.CommandName = strValue

Property Value


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.

Remarks

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.

Example

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.

Run Sample | View Source
See Also

ButtonField Members   Adding Button Fields to a GridView Control Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph