这是我Delete
点击后的功能。谁能告诉我如何做一个简单的确认功能?
ASP.net C#。
以前我有这个
ScriptManager.RegisterStartupScript(this,
this.GetType(),
"script",
"confirm('Are you sure you want to Delete Your Discussion?');",
true);
但上述代码在删除后运行。
protected void lnk_delete_Click(object sender, EventArgs e)
{
GridViewRow grdrow = (GridViewRow)((LinkButton)sender).NamingContainer;
string fieldID = grdrow.Cells[0].Text;
string query = "Delete from Comment where DiscussionID=@id";
SqlCommand cmd = new SqlCommand(query, cn);
cmd.Parameters.AddWithValue("@id", fieldID);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
string query1 = "Delete from Discussion where DIscussionID=@id";
SqlCommand cmd1 = new SqlCommand(query1, cn);
cmd1.Parameters.AddWithValue("@id", fieldID);
cn.Open();
cmd1.ExecuteNonQuery();
cn.Close();
GridView1.DataBind();
}