You always come accross a confirmation message "Are you sure you want to delete this item ? " while deleting an item. In web application basically we attach a javascript function with the OnClientClick event of the server control to ask user confirmation before delete the item.
So this is not a big problem if we have a single server control like Button control to call the javascript function through the OnClientClick event like:
function ConfirmDelete()
{
if(confirm("Are you sure you want to delete this item ?"))
{
return true;
}
else
{
return false;
}
}
But in case of GridView control if we need a confirmation message before deleting any row items from the grid then we have to bind the javascript function for each row's OnClientClick event of the grid control. This is a bit complex process. So we can have the other way to do this and can be done without binding the javascript function to each row's OnClientClick event of the grid.