You can handle the click event of the Command button using GridView.RowCommand Event. This event cccurs when a button is clicked in a GridView control.
Set the CommandName property of the Button control to a string value and check that value with GridViewCommandEventArgs in the RowCommand event of GridView. Check the following link.
GridView..RowCommand Event[
^]