如何实现全选删除,我现在可以实现单个删除,全选也只能删除一个

后台
public ActionResult sanku(decimal id)
{
var re = epcdb.SEMAIL.Find(id);
epcdb.SEMAIL.Remove(re);
epcdb.SaveChanges();

return View();
}

页面代码
<br> $(function () {<br> //全选或全不选 <br> $(&quot;#all&quot;).click(function () {<br> if (this.checked) {<br> $(&quot;#list :checkbox&quot;).prop(&quot;checked&quot;, true);<br> }<br> else {<br> $(&quot;#list :checkbox&quot;).prop(&quot;checked&quot;, false);<br> }<br> });<br> var ids = [];<br> $(&quot;input[type=&#39;button&#39;]&quot;).click(function () {<br> $(&#39;:checked:not(&quot;#all&quot;)&#39;).parents(&quot;tr&quot;).each(function () {<br> var id = $(this).data(&quot;id&quot;);<br> ids.push(id);</p> <pre><code> $.ajax({ url: &#39;/Email/sanku&#39;,// 请求的Url type: &#39;post&#39;,//提交方式s data: { id: ids},//参数Json格式 dataType: &quot;Text&quot;, //请求的返回类型 这里为text cache: false, //是否异步提交 }) }); }); $(function () { $(&quot;[data-toggle=&#39;popover&#39;]&quot;).popover(); }); }) &lt;/script&gt; </code></pre> <pre><code> </code></pre>

 public ActionResult sanku(decimal[] ids)
{
var re = epcdb.SEMAIL.Where(x => ids.Contains(x));
foreach (var r in re)
{
epcdb.SEMAIL.Remove(r);
}
epcdb.SaveChanges();
}
$(function () { //全选或全不选 $("#all").click(function () { if (this.checked) { $("#list :checkbox").prop("checked", true); } else { $("#list :checkbox").prop("checked", false); } }); //$("input[type='button']").click(function(){ // $(':checked:not("#all")').parents("tr").remove(); //}); var ids = []; $("input[type='button']").click(function () { $(':checked:not("#all")').parents("tr").each(function () { var id = $(this).data("id"); ids.push(id); $.ajax({ url: '/Email/sanku',// 请求的Url type: 'post',//提交方式s data: { id: ids},//参数Json格式 dataType: "Text", //请求的返回类型 这里为text cache: false, //是否异步提交 }) }); }); $(function () { $("[data-toggle='popover']").popover(); }); })$(function () { //全选或全不选 $("#all").click(function () { if (this.checked) { $("#list :checkbox").prop("checked", true); } else { $("#list :checkbox").prop("checked", false); } }); //$("input[type='button']").click(function(){ // $(':checked:not("#all")').parents("tr").remove(); //}); var ids = []; $("input[type='button']").click(function () { $(':checked:not("#all")').parents("tr").each(function () { var id = $(this).data("id"); ids.push(id); $.ajax({ url: '/Email/sanku',// 请求的Url type: 'post',//提交方式s data: { id: ids},//参数Json格式 dataType: "Text", //请求的返回类型 这里为text cache: false, //是否异步提交 }) }); }); $(function () { $("[data-toggle='popover']").popover(); }); })