Imar,
This book is great! I worked through it completely and am now going back and working through certain sections again, particularly concepts that I have never worked with before such as LINQ and the ListView control.
The Delete button, referenced on page 457, removes the item from the Picture table which is the source table for the web page. However, it does not remove the actual file from the virtual folder. Is there a way to do this within the ListView control? Also, how could an album be deleted? Of course, this would require removing the name from the PhotoAlbum, removing the associated data rows in the Picture table and removing the actual files from the virtual folder.
Below is my code that correctly removes an album. Is there another way to do this? As you can tell, I'm working in
VB.NET
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim photoAlbumId As Integer = Convert.ToInt32(DropDownList1.SelectedValue)
Dim myDatabaseContext As New SpaethFamilyDataContext
Dim pics = From p In myDatabaseContext.Pictures _
Where p.PhotoAlbum.Id = photoAlbumId _
Select p
For Each selectedDetail As Picture In pics
System.IO.File.Delete(Server.MapPath(selectedDetai l.ImageUrl))
myDatabaseContext.Pictures.DeleteOnSubmit(selected Detail)
Next
myDatabaseContext.SubmitChanges()
Dim Albm = From p In myDatabaseContext.PhotoAlbums _
Where p.Id = photoAlbumId _
Select p
myDatabaseContext.PhotoAlbums.DeleteAllOnSubmit(Al bm)
myDatabaseContext.SubmitChanges()
End Sub
End Class