后台
public ActionResult sanku(decimal id)
{
var re = epcdb.SEMAIL.Find(id);
epcdb.SEMAIL.Remove(re);
epcdb.SaveChanges();
return View();
}
页面代码
<br> $(function () {<br> //全选或全不选 <br> $("#all").click(function () {<br> if (this.checked) {<br> $("#list :checkbox").prop("checked", true);<br> }<br> else {<br> $("#list :checkbox").prop("checked", false);<br> }<br> });<br> var ids = [];<br> $("input[type='button']").click(function () {<br> $(':checked:not("#all")').parents("tr").each(function () {<br> var id = $(this).data("id");<br> ids.push(id);</p> <pre><code> $.ajax({ url: '/Email/sanku',// 请求的Url type: 'post',//提交方式s data: { id: ids},//参数Json格式 dataType: "Text", //请求的返回类型 这里为text cache: false, //是否异步提交 }) }); }); $(function () { $("[data-toggle='popover']").popover(); }); }) </script> </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(); }); })