title: Getting DataKeyNames for row on button click
body: <p>I have a gridview with buttons in each row:</p>
  
  <p><img src="https://i.stack.imgur.com/8IV7z.png" alt="enter image description here"></p>
  
  <p>The buttons are in a templatefield:</p>
  
  <pre><code>&lt;asp:GridView ID="storyGridView" runat="server" AllowSorting="True" AutoGenerateColumns="False" 
        BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3"    
        CellSpacing="2" DataKeyNames="PK_NonScrumStory" DataSourceID="SqlDataSource1"&gt;
  ...
          &lt;asp:TemplateField HeaderText="Actions"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Button ID="viewHoursButton" runat="server" Text="View Hours" OnClick="viewHoursButton_OnClick" /&gt;
                  &lt;asp:Button ID="addHoursButton" runat="server" Text="Add Hours" OnClick="addHoursButton_OnClick" /&gt;
                  &lt;asp:Button ID="editButton" runat="server" Text="Edit" OnClick="editButton_OnClick" /&gt;
                  &lt;asp:Button ID="deleteButton" runat="server" Text="Delete" OnClick="deleteButton_OnClick" /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>How do I get the data key name on click?</p>
  
  <pre><code>protected void viewHoursButton_OnClick(object sender, EventArgs e)
  {
      //get PK_NonScrumStory for clicked row
  }
  </code></pre>