日期:2014-05-16 浏览次数:20528 次
//前台批量删除按钮
<asp:Button ID="btnDelete" runat="server" OnClick="btnDelete_Click" Text="批量删除" OnClientClick="javascript:confirm('删除后将不能恢复,确定要删除吗?')"> </asp:Button>
//后台单击事件
protected void btnDelete_Click(object sender, EventArgs e)
{
BLL.tourline tlbll = new BLL.tourline();
for (int i = 0; i < this.rptLineList.Items.Count; i++)
{
int id = Convert.ToInt32(((HiddenField)this.rptLineList.Items[i].FindControl("hidId")).Value);
CheckBox ckb = (CheckBox)this.rptLineList.Items[i].FindControl("chkId");
if (ckb.Checked)
{
tlbll.Delete(id);
}
}
lie = Request.QueryString["lm_id"].ToString();
FillRepeater(lie);
}
<asp:Button ID="btnDelete" runat="server" OnClick="btnDelete_Click" Text="批量删除" OnClientClick="cheBox() "> </asp:Button>
function cheBox() {
// 判断是否至少选择一项
var checkedNum = $("input[name='checkboxname']:checked").length;
if(checkedNum == 0) {
alert("请选择至少一项!");
return;
}
// 批量选择
if(confirm("确定要删除所选项目?")) {
}