title: How to send multiple rows by selecting checkbox in datatable and send it to controller for update?
body: <p>I am working in ASP.NET MVC.
   I am having a datatable with checkbox options to select multiple rows to send to controller for bulk update. As, I am having two different funtions with two different buttons in same view, I cant able to use Form submission method.</p>
  
  <p>I am trying to send via Ajax method. But, cant able to send selected rows into an array.</p>
  
  <p>Codes that I tried below:
  <strong>Table:</strong></p>
  
  <pre><code>&lt;table cellspacing="1" cellpadding="2" style="width: 100%;" id="tblStatus" class="table table-striped table-hover table-bordered table-hd"&gt;
  &lt;thead&gt;
      &lt;tr class="gridheader"&gt;
          &lt;td valign="middle" align="center" style="width: 2%;"&gt;
              &lt;input id="chkAll" onclick="javascript: checkAll();" type="checkbox" name="chkAll" /&gt;
          &lt;/td&gt;
          &lt;td style="width: 25%;" &gt;Data1&lt;/td&gt;
          &lt;td style="width: 25%;" &gt;Data2&lt;/td&gt;
          &lt;td style="width: 25%;" &gt;Data3&lt;/td&gt;
          &lt;td style="width: 25%;" &gt;Data4&lt;/td&gt;   
         &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @if (Model != null)
          {      
           foreach (var m in Model)
           {
               &lt;tr&gt;
                   &lt;td valign="middle" align="center" style="width: 2%;"&gt;
                       &lt;input id="chkBox" name="chkBox" type="checkbox" onclick="javascript: checkManual();" value="" /&gt;
                   &lt;/td&gt;
                   &lt;td&gt;Data1&lt;/td&gt;
                   &lt;td&gt;Data2&lt;/td&gt;
                   &lt;td&gt;Data3&lt;/td&gt;
                   &lt;td&gt;Data4&lt;/td&gt;                 
                 &lt;/tr&gt;
           }
          }    
      &lt;/tbody&gt;
   &lt;/table&gt;
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code> [HttpPost]
     public ActionResult Update(List&lt;StatusVM&gt; data1)
     {
         return View();
     } 
  </code></pre>
  
  <p><strong>Button to Update:</strong></p>
  
  <pre><code> &lt;div class="btn-group"&gt;
        &lt;button @*type="submit"*@ id="btnUpdate" onclick="GetData();" name="btnUpdate" class="btn btn-block btn-success btn-flat"&gt;&lt;span class="hide-on-mobile"&gt;Update &lt;/span&gt;&lt;i class="fa fa-save"&gt;&lt;/i&gt;&lt;/button&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p><strong>Javascript-Where I am trying to send data:</strong></p>
  
  <pre><code> function GetData() {
          var table = $('#tblStatus').DataTable();
          if ($('[name="chkBox"]:checked').length &lt;= 0) {
              alert('Please select minimum one data');
          }
          else {
               var CData = new Array();
              var dd;//= $('[name="chkBox"]:checked').toArray();
              $('[name="chkBox"]:checked').each(function (data) {
                   var rowData =table.row(this).data();
              CData.push(rowData);
              });
                 $.ajax({
                  type: "POST",
                  url: "/Test/Update",
                  contentType: "application/json;",
                  headers: { 'RequestVerificationToken': gettoken() },
                  data: JSON.stringify({ data1: CData }),
              });
          }
      }
  </code></pre>
  
  <p>How to fix this? I want sent rows data that selected with checkbox only. Kindly help.</p>