I'm running into an issue having a "delete confirmation" pop up if someone selects the "Delete" link in a gridview.
More specifically, the pop up does work when clicking the "Delete" link, but the pop-up also comes up if I click the "Edit" link next to it in the same cell, and then click the "Cancel" button for the update operation when it gives the options of "Update" and "Cancel".
I believe it's because I am accessing the Delete control by index, and when I click the Edit button, the Cancel button for the "Edit" link then takes the index of where the "Delete" button is by default. Obviously the pop-up for the "Cancel" operation is not desired. I'm using the built-in "Allow Editing" and "Allow Deleting" options for the gridview. Below is the code I'm using.
protected void actionPlanGirdView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// reference the Delete LinkButton
LinkButton db = (LinkButton)e.Row.Cells[0].Controls[2];
db.OnClientClick = "return confirm('Are you certain you want to delete the record?');";
}
}