1、View
$("#btnDelete").click(function () {
var delString = ""; //獲取刪除id字符串
//獲取選中的checkbox
for (var i = 0; i < $("#txtPageNum").val() ; i++) {
delStr = $("#rptList_hidId_" + i).val();
delString += delStr + ",";
}
}
//操作
$.get("DelLawyer", { strId: delString }, function (data) {
if (data == "ok") {
window.location.replace("list");
alert("刪除成功");
}
else {
alert("刪除失敗");
}
}, 'text');
}
else {
alert("請選擇要刪除的項");
}
})
2、控制器
public ActionResult DelLawyer(string strId)
{
try
{
string[] strArrs = strId.Split(',');
for (int i = 0; i < strArrs.Length - 1; i++)
{
//刪除具體操作
int delId = Convert.ToInt32(strArrs[i]);
UserDal.F_User_DelLawyer(delId);
}
return Content("ok");
}
catch (Exception ex)
{
return Content("刪除失敗"+ex.Message);
}
}