Click here to Skip to main content
15,918,243 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview in which I have a command field Delete button in all the rows.The Delete button is working fine and deleting the record when clicked but it is not showing the 'Are you sure you want to delete this record' popup on the screen before deleting.I have added the following code to my RowDataBound event of the Gridview.

if (e.Row.RowType == DataControlRowType.DataRow &&gvrecord.EditIndex==e.Row.RowIndex)
{
((LinkButton)e.Row.Cells[15].Controls[0]).Attributes["onclick"] = "return confirm('Are you certain you want to delete this record!');";
}

But,it is not working.I can't figure out what the problem is.Can anybody please help?
Posted

C#
<script language="javascript" type ="text/javascript" >


function DeleteConfirmation() {
    if (confirm("Está seguro que quiere eliminar la regla?") == true) {
        return true;
    }
    else {
        return false;
    }
}
</script>



Call this function on linkbutton

OnClientClick="return DeleteConfirmation();"
 
Share this answer
 
try it once...

C#
if (e.Row.RowType == DataControlRowType.DataRow &&gvrecord.EditIndex==e.Row.RowIndex)
{
((LinkButton)e.Row.Cells[15].Controls[0]).Attributes["onclick"] = "javascript:return confirm('Are you certain you want to delete this record!');";
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900