jQuery - efficiently grab data from an asp.net gridview
<p>I have an asp.net gridview which is output as a table in HTML.  There's a series if <code>&lt;input&gt;</code> checkboxes that tell me if the user wants to export the data into excel.  </p>

<p>When a checkbox is checked I want to pull the corresponding rows ID from the table.  I don't want to go back to the server because the data is right there and the new data could be out of sync.  I also do not want to persist with State for the same reasons MS didnt do it in the first place.  </p>

<p>How can I gather the checked row ID's with jQuery?</p>

<p>Example (where Export is a checkbox)</p>

<p>Export         ID<br />
  [ true ]      1<br />
  [ false ] 2 <br /> 
  [ true ] 3 <br /></p>

<p>So, the jquery result should be [1,3].  Then I can take this result and use $.get to obtain the results.</p>

<p><hr />Sample HTML</p>

<pre><code>            &lt;div style=""&gt;
                &lt;div&gt;
    &lt;table class="cssTable" cellspacing="1" GroupIndent="15px" AllowColMoving="True" AllowGrouping="True" AllowColSizing="True" border="0" id="_ctl0_ContentPlaceHolder1_cwgBatch"&gt;
        &lt;tr class="headTableRow"&gt;
            &lt;th scope="col"&gt;Export&lt;/th&gt;&lt;th scope="col"&gt;&amp;nbsp;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$batchID&amp;#39;)"&gt;ID&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$DueDate&amp;#39;)"&gt;Due&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$repName&amp;#39;)"&gt;Rep&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$area&amp;#39;)"&gt;Area&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$Region&amp;#39;)"&gt;Region&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$territory&amp;#39;)"&gt;AreaRegion&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$batchDate&amp;#39;)"&gt;Started&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$Submitted&amp;#39;)"&gt;Submitted&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$Acknowledged&amp;#39;)"&gt;col10&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$Rejected&amp;#39;)"&gt;col11&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$ContentPlaceHolder1$cwgBatch&amp;#39;,&amp;#39;Sort$Approved&amp;#39;)"&gt;col12&lt;/a&gt;&lt;/th&gt;
        &lt;/tr&gt;&lt;tr&gt;
            &lt;td&gt;
                            &lt;span class="enabledExport"&gt;&lt;input id="_ctl0_ContentPlaceHolder1_cwgBatch__ctl2_exportCb" type="checkbox" name="_ctl0:ContentPlaceHolder1:cwgBatch:_ctl2:exportCb" /&gt;&lt;/span&gt;        
                        &lt;/td&gt;&lt;td&gt;&lt;a href=Page.aspx?batchID=1&gt;View&lt;/a&gt;&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;20115 &lt;/td&gt;&lt;td nowrap="nowrap"&gt;
            A Dood&lt;/td&gt;&lt;td&gt;51&lt;/td&gt;&lt;td&gt;R1&lt;/td&gt;&lt;td&gt;51R1&lt;/td&gt;&lt;td&gt;5/17/2011 00:03:08 PM&lt;/td&gt;&lt;td&gt;5/24/2011 12:47:21 AM&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;&lt;tr class="oddTableRow"&gt;
            &lt;td&gt;
                            &lt;span class="enabledExport"&gt;&lt;input id="_ctl0_ContentPlaceHolder1_cwgBatch__ctl3_exportCb" type="checkbox" name="_ctl0:ContentPlaceHolder1:cwgBatch:_ctl3:exportCb" /&gt;&lt;/span&gt;        
                        &lt;/td&gt;&lt;td&gt;&lt;a href=Page.aspx?batchID=2&gt;View&lt;/a&gt;&lt;/td&gt;&lt;td&gt;
            2&lt;/td&gt;&lt;td&gt;20115 &lt;/td&gt;&lt;td nowrap="nowrap"&gt;
            Some Girl&lt;/td&gt;&lt;td&gt;B9&lt;/td&gt;&lt;td&gt;R2&lt;/td&gt;&lt;td&gt;B9R2&lt;/td&gt;&lt;td&gt;5/18/2011 00:31:15 PM&lt;/td&gt;&lt;td&gt;5/19/2011 
            12:21:18 AM&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;&lt;tr&gt;
            &lt;td&gt;
                            &lt;span class="enabledExport"&gt;&lt;input id="_ctl0_ContentPlaceHolder1_cwgBatch__ctl4_exportCb" type="checkbox" name="_ctl0:ContentPlaceHolder1:cwgBatch:_ctl4:exportCb" /&gt;&lt;/span&gt;        
                        &lt;/td&gt;&lt;td&gt;&lt;a href=Page.aspx?batchID=3&gt;View&lt;/a&gt;&lt;/td&gt;&lt;td&gt;
            3&lt;/td&gt;&lt;td&gt;20115 &lt;/td&gt;&lt;td nowrap="nowrap"&gt;Bart Simpson&lt;/td&gt;&lt;td&gt;
            B8&lt;/td&gt;&lt;td&gt;R1&lt;/td&gt;&lt;td&gt;B8R1&lt;/td&gt;&lt;td&gt;5/10/2011 00:47:12 PM&lt;/td&gt;&lt;td&gt;5/11/2011 12:26:51 AM&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;&lt;tr class="oddTableRow"&gt;
            &lt;td&gt;
                            &lt;span class="enabledExport"&gt;&lt;input id="_ctl0_ContentPlaceHolder1_cwgBatch__ctl5_exportCb" type="checkbox" name="_ctl0:ContentPlaceHolder1:cwgBatch:_ctl5:exportCb" /&gt;&lt;/span&gt;        
                        &lt;/td&gt;&lt;td&gt;&lt;a href=Page.aspx?batchID=4&gt;View&lt;/a&gt;&lt;/td&gt;&lt;td&gt;
            4&lt;/td&gt;&lt;td&gt;20115 &lt;/td&gt;&lt;td nowrap="nowrap"&gt;Somebody Name&lt;/td&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;
            R5&lt;/td&gt;&lt;td&gt;5R5&lt;/td&gt;&lt;td&gt;5/19/2011 00:46:53 AM&lt;/td&gt;&lt;td&gt;5/19/2011 12:48:54 AM&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/div&gt;                
            &lt;/div&gt;
</code></pre>
