gridview Delete confirm box in codebehind using ASP.NET.
In Row_Created Event of grid view write this line of code
protected
void GridView1_RowCreated(object sender, GridViewRowEventArgs e){
if
(e.Row.RowType == DataControlRowType.DataRow){
LinkButton tmpBtn = (LinkButton)e.Row.Cells[e.Row.Cells.Count - 1].Controls[e.Row.Cells[e.Row.Cells.Count - 1].Controls.Count - 1];
if
(tmpBtn != null && tmpBtn.Text != "Cancel")tmpBtn.Attributes.Add(
"onclick", "javascript:if (!confirm('Are you sure you want to delete this event?')) return false;");}
}
protected
void GridView1_RowEditing(object sender, GridViewEditEventArgs e){
Response.Redirect(
"editevent.aspx?eventid=" + GridView1.DataKeys[e.NewEditIndex].Value);}
protected
string GetDate(object date){
if
(date != DBNull.Value && date.ToString() != ""){
return
DateTime.Parse(date.ToString()).ToString("dd-MMM-yyyy");}
else
return
"";}
}