I have a Gridview which displays the filenames in the database.
I have written code for deleting filename entry from database, but I also want to delete it from the directory, so how do I retrieve filename from Gridview ?
I don't want to execute another select command for retrieving filename.
Code :
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int Fid = (int)GridView1.DataKeys[e.RowIndex].Value;
sdsFiles.DeleteCommand = "Delete from Files where Fid = @id";
sdsFiles.DeleteParameters.Clear();
sdsFiles.DeleteParameters.Add("id",Fid.ToString());
sdsFiles.Delete();
System.IO.Directory.Delete(Server.MapPath("~/Data/"));
}
Thanks.