20160113 js中选择多个check一块删除
js中
<script type="text/javascript"> $(document).ready(function (e) { $("#Button2").click(function () { if (confirm("确认要删除么!")) { var all = $(".xuanzhong"); var code = ""; for (var i = 0; i < all.length; i++) { if (all.eq(i)[0].checked) { code += all.eq(i).val()+"|"; } } code = code.substring(0, code.length - 1); $.ajax({ url: "quanxuanshanchu.aspx", type:"POST", data: { ids:code }, datatype: "TEXT", success: function (data) { alert(data); window.location.href = "gongyingshang.aspx"; } }); } })
后台操作
LXMallDBDataContext context = new LXMallDBDataContext(); //取出Ajax传过来的值 string uid = Request["ids"].ToString(); string[] codes; codes = uid.Split('|'); for (int i = 0; i < codes.Length; i++) { Goods_Supplier data = context.Goods_Supplier.Where(r => r.ids == Convert.ToInt32(codes[i])).First(); context.Goods_Supplier.DeleteOnSubmit(data); } context.SubmitChanges(); Response.Write("删除成功!!!!!!"); Response.End();