title: When checkbox checked get datagrid value using jquery
body: <p>I have a checkbox template field within a gridview in c#, this field also has a hidden field with the id behind it. I want to use jQuery to raise an event on click of the checkbox to grab a datakey value so I can run a query through jQuery and add the checked item to the database. I have seen examples that get datakeys when an overall button is clicked but I want this to happen on each checkbox clicked within the gridview. I currently get "undefined" when trying to access the id.</p>
  
  <p>C# within the gridview</p>
  
  <pre><code>&lt;ItemTemplate&gt;
       &lt;asp:CheckBox ID="CheckBox" CssClass="checkbox" runat="server" /&gt;
       &lt;asp:HiddenField ID="idnum" runat="server" Value='&lt;%# Eval("id") %&gt;' /&gt;
  &lt;/ItemTemplate&gt;
  </code></pre>
  
  <p>jQuery</p>
  
  <pre><code>$(document).ready(function () {
             var gridResults = document.getElementById('&lt;%= grdResults.ClientID %&gt;');
  
             $("form input:checkbox").click(function (e) {
                     var id = $(this).next('#idnum').val();
                     alert(id);
                     return false;                                        
             });
  }); 
  </code></pre>