클릭 후 내 Delete
기능입니다. 누구나 간단한 확인 기능을 수행하는 방법을 보여줄 수 있습니까?asp.net에 대한 확인 메시지 BOX 기능?
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 [email protected]";
SqlCommand cmd = new SqlCommand(query, cn);
cmd.Parameters.AddWithValue("@id", fieldID);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
string query1 = "Delete from Discussion where [email protected]";
SqlCommand cmd1 = new SqlCommand(query1, cn);
cmd1.Parameters.AddWithValue("@id", fieldID);
cn.Open();
cmd1.ExecuteNonQuery();
cn.Close();
GridView1.DataBind();
}
당신은 체크 아웃해야합니다 (http://blogs.msmvps.com/jcoehoorn/blog/ [이미) 우리가 AddWithValue을 (사용을 중지 할 수 있습니까?] 2014/05/12/can-we-stop-using-addwithvalue-already /)'.AddWithValue()'사용을 중지하십시오. 예기치 않은 놀라운 결과를 초래할 수 있습니다 ... –
또한 클라이언트 삭제 요청을 보내기 전에 당신이 정말로 필요하지 않으면 그것을 별도의 단계로 만들지 마십시오. –