Implementation method:
Double-click the Onrowdatabound event of the GridView;
Add the code to the GridView1_RowDataBound () method in the background, and the final code looks like this:
protected void GridView1_RowDataBound (object sender, GridViewRowEventArgs e)
{
//If it is a bound data row
if (E.row.rowtype = = Datacontrolrowtype.datarow)
{
if (e.row.rowstate = = Datacontrolrowstate.normal | | e.row.rowstate = = Datacontrolrowstate.alternate)
{
((LinkButton) E. ROW.CELLS[6]. Controls[0]). Attributes.Add ("onclick", "Javascript:return confirm (' You are sure to delete: \" "+ e.row.cells[1]. Text + "\"? ");
}
}
}
protected void GridView1_RowDataBound (object sender, GridViewRowEventArgs e)
{
if (E.row.rowtype = = Datacontrolrowtype.datarow && e.row.cells[0]. CONTROLS.COUNT>0)
{
LinkButton lb = (LinkButton) e.row.cells[0]. Controls[0];
Lb. Attributes.Add ("onclick", "return confirm (' Are you sure you want to delete this record?") ‘);");
}
}
GridView Popup Delete Confirmation dialog box