title: Trying to get checkbox checked rows values from gridview using Javascript
body: <p>I have gridview with checkbox as first column and I am trying to get the selected checkbox  complete row values  using Javascript function attached to check box mentioned below.</p>
  <p>I tried with the different approach but got stuck in middle that is why I posted here again.</p>
  <p>But some how I am not getting inside to the for loop and I am not sure where I am getting error in this code.</p>
  <p>Javascript function:</p>
  <pre><code>function checkForVirtual(){
      var GridView = document.getElementById('&lt;%=gvPRCertInfo.ClientID %&gt;');
  
      if (GridView.rows.length &gt; 0) {
          alert('check');
          for (Row = 1; Row &lt; GridView.rows.length; Row++) {                  
               alert(&quot;check 2 times&quot;); 
                
              if (GridView.rows[Row].cell[1].type == &quot;checkbox&quot;) {
                /// not getting into this 
               ///  alert is not firing even if the checkbox is there 
                  alert('inside'); 
                  if (GridView.rows[Row].cell[0].childNodes[0].checked) {
                      alert('checked');
                      var type = GridView.rows[Row].cell[3].childNodes[0].val();
                      alert(type);
                  }
              }
          }
      }
  }
  </code></pre>
  <p>This is my grid view:</p>
  <pre><code>&lt;asp:GridView ID=&quot;gvPRCertInfo&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot; GridLines=&quot;None&quot;
                          
       OnRowDataBound=&quot;gvPRCertInfo_RowDataBound&quot;
       CssClass=&quot;data responsive&quot;&gt;
     &lt;Columns&gt;
     &lt;asp:TemplateField HeaderText=&quot;Select&quot; SortExpression=&quot;&quot;&gt;
          &lt;HeaderTemplate&gt;
              &lt;asp:CheckBox ID=&quot;chkboxSelectAll&quot; runat=&quot;server&quot; AutoPostBack=&quot;true&quot;  OnCheckedChanged=&quot;chkboxSelectAll_CheckedChanged&quot;/&gt;
           &lt;/HeaderTemplate&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:CheckBox ID=&quot;chkCert&quot; AutoPostBack=&quot;true&quot; OnCheckedChanged=&quot;chkCert_CheckedChanged&quot; OnClick=&quot;Javascript:checkForVirtual();&quot; runat=&quot;server&quot; /&gt;                                    
              &lt;input type=&quot;hidden&quot; id=&quot;hdnCertId&quot; runat=&quot;server&quot; value='&lt;%# DataBinder.Eval(Container.DataItem, &quot;CertId&quot;) %&gt;' /&gt;
          &lt;/ItemTemplate&gt;
       &lt;/asp:TemplateField&gt;
      &lt;asp:BoundField DataField=&quot;CertificateID&quot; HeaderText=&quot;Certificate ID&quot; HeaderStyle-HorizontalAlign=&quot;Center&quot; /&gt;
         &lt;asp:BoundField DataField=&quot;partID&quot; HeaderText=&quot;Part Number&quot; HeaderStyle-HorizontalAlign=&quot;Center&quot; /&gt;
                    ..............................
  
      &lt;/Columns&gt;
    .........................
   .......................
   &lt;/asp:GridView&gt;
  </code></pre>
  <p>Would any one please help on this one?</p>