I am deleting a row from gridview for which i have used gridview’s default delete command field. On clicking, the gridview row deleting command gets fired and the selected row gets deleted. All good till now.
But before the row gets deleted, i need to set confirmation message to user. On clicking of OK button the row should get deleted else not (on click of cancel button).
I have the code as;
return confirm('Are you sure to delete?');
But this works fine if there is a linkbutton (instead of command field) as i could easily write on OnClick event of linkbutton and could add the attributes in Gridview RowDataBound event.
How the same would work for command’s field delete button? Please guide!
Thanks!
This article explains how to do exactly what you need:
http://www.codeproject.com/KB/webforms/Gridview_Delete_confirmLS.aspx
And here is the code you need to do it: