On my website I use simple file management. User can upload files, see the list and delete them. In database I have one table Files
which contain information about files (file name, description, insert date).
I display all the files in GridView
control with SQLDataSource
.
DeleteCommand="DELETE FROM Files WHERE id = @id"
What I want to do is to delete the asocciated file when user deletes row from table. I was trying to do this in OnDeleting
event but it seams that I have to execute another SELECT
to get file name. Is it the only way to do this? Or is it any other better way? Or how to get the file name from inside the OnDeleting
event?
EDITED: Databse is SQL Server, but it is not important in this case. I store files in file system. In database there are only names of files.