Get "delete" answer before delete "File" in GridView

calvin

Regular
Joined
Nov 6, 2003
Messages
71
Hi,

I got a Image gridview in a page. There is one delete button column to delete record. It is no problem to delete data in the database, but what I need is delete the image file as well if user click "OK" from the confirmation dialog. How can I get the "answer" whether user is click "OK" button or "Cancel" button?

This is my code for delete the image record.

OnClientClick="return confirm('Are you sure you want to delete this record?');"


So, what method I should use for delete the image file? RowDeleting or RowDeleted.

Protected Sub GridView1_RowDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeletedEventArgs) Handles GridView1.RowDeleting
File.Delete(Server.MapPath(".\\") + "..Photo/" + imgName)
End Sub


Calvin
 
Back
Top