Delete Confirmation
-
Hi, I'm having a problem to show a confirmation messageBox when i press my LinkButton inside my gridview..Currently i'm using gridview_RowDataBound Event :
protected void gvAllProjects_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lbDelete = (LinkButton)e.Row.FindControl("lnkDelBtn"); lbDelete.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete Customer : " + DataBinder.Eval(e.Row.DataItem, "mainproject_cust") + " ?')"); } }
it show me the confirmation messagebox, when i press the "Ok" button the data is succesfully deleted but when i press "cancel" it delete my data too :confused:..pls anyone give me a solution how to detect when user press "Ok" or "Cancel" button. Thank u for the helpRegards, Tomi
-
Hi, I'm having a problem to show a confirmation messageBox when i press my LinkButton inside my gridview..Currently i'm using gridview_RowDataBound Event :
protected void gvAllProjects_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lbDelete = (LinkButton)e.Row.FindControl("lnkDelBtn"); lbDelete.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete Customer : " + DataBinder.Eval(e.Row.DataItem, "mainproject_cust") + " ?')"); } }
it show me the confirmation messagebox, when i press the "Ok" button the data is succesfully deleted but when i press "cancel" it delete my data too :confused:..pls anyone give me a solution how to detect when user press "Ok" or "Cancel" button. Thank u for the helpRegards, Tomi
T.EDY wrote:
lbDelete.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete Customer : " + DataBinder.Eval(e.Row.DataItem, "mainproject_cust") + " ?')");
Hi, change yr code as per below.
lbDelete.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete Customer : " + DataBinder.Eval(e.Row.DataItem, "mainproject_cust") + " ?')**; return false;**");
Thanks, Sun Rays To get something you must have to try once. My Articles
-
Hi, I'm having a problem to show a confirmation messageBox when i press my LinkButton inside my gridview..Currently i'm using gridview_RowDataBound Event :
protected void gvAllProjects_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lbDelete = (LinkButton)e.Row.FindControl("lnkDelBtn"); lbDelete.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete Customer : " + DataBinder.Eval(e.Row.DataItem, "mainproject_cust") + " ?')"); } }
it show me the confirmation messagebox, when i press the "Ok" button the data is succesfully deleted but when i press "cancel" it delete my data too :confused:..pls anyone give me a solution how to detect when user press "Ok" or "Cancel" button. Thank u for the helpRegards, Tomi