System.Web.UI.WebControls Namespace GridView Class
.NET Framework version 2.0
Occurs when a button within a GridView control is clicked.
[ VB ]
Public Event RowCommand As GridViewCommandEventHandler
[ C# ]
public event GridViewCommandEventHandler RowCommand;
[ C++ ]
public: __event GridViewCommandEventHandler* RowCommand;
In [ JScript ], you can handle the events defined by a class, but you cannot define your own.
The RowCommand event is raised whenever any button associated with a row in the GridView is clicked. This provides for programmatically determining which specific command button is clicked and take appropriate action.
This event is commonly used to handle button controls with a given CommandName value in the GridView control.
Information related to the RowCommand event is passed via a GridViewCommandEventArgs object to the method assigned to handle the event. The following GridViewCommandEventArgs properties provide information specific to this event.
The following example illustrates a way to handle the RowCommand event of a GridView control.
Whenever any of the LinkButton controls within the GridView is clicked, data from the selected row is obtained using the three GridViewCommandEventArgs properties described above.
This information is then processed and added to or removed from another GridView control.
The below snippet shows how to attach a handler for the event.
<asp:gridview id = "myGridView" runat = "server"
onRowCommand = "updateCart" ... >
The below shows how the handler method is defined.
GridView Members GridViewCommandEventArgs