You can use OnROwCommand Event like this...
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="act_id"
DataSourceID="SqlDataSource1" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField="act_id" HeaderText="act_id" ReadOnly="True" SortExpression="act_id" />
<asp:BoundField DataField="heading" HeaderText="heading" SortExpression="heading" />
<asp:BoundField DataField="category_id" HeaderText="category_id" SortExpression="category_id" />
<asp:TemplateField >
<ItemTemplate >
<asp:button CommandName="myButton1" CommandArgument='<%# Eval("act_id") %>' runat ="server" ID="button" Text ='<%#eval("heading") %>' OnClick ="f" > </asp:button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
In the code behind..
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int act_id = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "myButton1")
{
string textOnTheButton=Convert.ToString(e.CommandSource);
}
}
Hope this helps