This is a migrated thread and some comments may be shown as answers.

delete associated file in gridview delete

1 Answer 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Buz Barnes
Top achievements
Rank 1
Buz Barnes asked on 31 Jul 2008, 09:18 PM
I know this is something simple but i am trying to delete the associated images on records that are deleted from a Rad gridview auto delete link.  I have images (up to 15) associated with each record in an images table.  When i delete the record i don't want to abandon the images. 
I'm not sure where to put a file delete function in the delete routine.  I'm guessing i need to make sure that the parent record is deleted before i start deleting the actual images but i need the record id to look up the images that were associated with it in the images table.  If anyone has an example or can tell me where to start I would be very grateful.  I'm not even sure how to search for this in the forums.

1 Answer, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 2
answered on 31 Jul 2008, 09:25 PM
yeah, I would do something like:

protected
void UserDeletedRecord(int recNumber)
{
    if(Record.GetRecord(recNumber).Delete())
   {
        FileInfo[] fileList = GetFileListByRecord(recNum);
        foreach (var info in fileList) 
       {
            info.Delete();
        }
     }
}

Sean~

Tags
Grid
Asked by
Buz Barnes
Top achievements
Rank 1
Answers by
Sean
Top achievements
Rank 2
Share this question
or