You can fire the
OnRowCommand
event of GridView. On row command get the clicked row through
CommandSource
property as following way -
<asp:GridView runat="server" ID="grd1" AutoGenerateColumns="False" OnRowCommand="grd1_OnRowCommand">
<Columns>
<asp:BoundField HeaderText="Code" DataField="Code" />
<asp:BoundField HeaderText="Name" DataField="Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" ID="gridBtn" Text="Click" CommandArgument="Get" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void grd1_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
var gvRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
var col1 = gvRow.Cells[0].Text;
var col2 = gvRow.Cells[1].Text;
}