我有一些动态生成的清单项目。当用户删除它们时,应出现确认框。我怎样才能做到这一点 ?
protected void btndelete_Click(object sender, EventArgs e)
{
try
{
string conn = ConfigurationManager.ConnectionStrings["sqlconn"].ConnectionString;
SqlConnection con = new SqlConnection(conn);
con.Open();
check:
if (CheckBoxList1.SelectedItem != null)
{
foreach (ListItem l in CheckBoxList1.Items)
{
if (l.Selected)
{
SqlCommand cmd = new SqlCommand("Drop Table " + l, con);
cmd.ExecuteNonQuery();
Label4.ForeColor = Color.Red;
Label4.Text = " PaperSet Deleted successfully";
CheckBoxList1.Items.Remove(l);
papersetlist.Items.Remove(l);
Psetlist.Items.Remove(l);
goto check;
}
}
}
con.Close();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
这是删除按钮事件代码。