功能:CheckBox选中所选择项,点击 删除所选 Button删除所选项
实现代码:
protected void BT_del_Click(object sender, EventArgs e)
{
CheckBox cb = new CheckBox();
for (int i = 0; i < DataGrid1.Items.Count; i++)
{
cb = (CheckBox)DataGrid1.Items[i].Cells[0].FindControl("CheckItem");
if (cb.Checked)
{
string sql = "Delete from DB_qiye_news where id=" + DataGrid1.Items[i].Cells[7].Text + "";//获取再DataGrid中的ID值
SqlHelper.DelAllSQL(sql,"main.aspx");//操作删除语句并且返回传去的页面
}
}
}
参考网上源码!