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 = ; i < all.length; i++) {
if (all.eq(i)[].checked) { code += all.eq(i).val()+"|";
}
}
code = code.substring(, code.length - );
$.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 = ; 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();
上一篇:Gramar


下一篇:C#基础-事件 继承类无法直接引发基类的事件