How can I get a value of the DataKeyName of a GridView Row when I have a button inside a row that have an OnClick event. In my OnClick event of my button I want to get a the DataKeyName of the row where the button resides.
Is this possible?
<asp:GridView ID="myGridView" run="server">
<Columns>
<asp:TemplateField HeaderText="Column 1">
<ItemTemplate>
... bunch of html codes
<asp:Button ID="myButton" UseSubmitBehavior="false" runat="server" Text="Click Me" onclick="btnClick_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
In my codebehind
protected void btnClick_Click(object sender, EventArgs e)
{
// How can I get the DataKeyName value of the Row that the Button was clicked?
}