Update, I found a solution to this. In the situation where you are using the auto-generated Insert and Delete buttons for a .NET gridview, and you want to access the delete button programatically, I did so with the below, accessing the Text
property of the LinkButton. The inner if
statement checks to see if the LinkButton is the Delete link, as if you also use an auto-generated Insert link, that index position can be the place of the Cancel button for the Update/Cancel combo when you click Insert in the Gridview.
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];
if (db.Text == "Delete")
{
db.OnClientClick = "return confirm('Are you certain you want to delete the record?');";
}
}
}