<asp:templatefield xmlns:asp="#unknown">
<itemtemplate>
<asp:button id="AddButton" runat="server">
CommandName="AddToCart"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
Text="Add to Cart" />
</asp:button></itemtemplate>
</asp:templatefield>
protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "AddToCart")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
}
}
Hope this will help you...