protected void AlbumFormView_DataBound(object sender, EventArgs e)
 {
     if (artistId == null)
     {
         var artistName = AlbumFormView.FindControl("ArtistName");
         artistName.Visible = false;
     }
 }
        public void AlbumFormView_UpdateItem(int AlbumId)
        {
            AlbumArtist item;

            try {
                item = Service.GetAlbumById(AlbumId);
            } catch {
                ModelState.AddModelError(String.Empty, "An error occured when getting the album from the database");
                return;
            }
            if (item == null)
            {
                ModelState.AddModelError(String.Empty, String.Format("Album with id {0} was not found", AlbumId));
                return;
            }

            if (TryUpdateModel(item))
            {
                try {
                    Service.SaveAlbum(item);

                    try {
                        var picUpload = AlbumFormView.FindControl("PicUpload") as FileUpload;
                        if (picUpload.HasFile)
                        {
                            Service.SaveAlbumArt(picUpload.FileContent, item.AlbumID);
                        }

                        this.SetTempData("SuccessMessage", "The album was saved.");
                        Response.RedirectToRoute("AlbumDetails", new { id = item.AlbumID });
                        Context.ApplicationInstance.CompleteRequest();
                    } catch {
                        ModelState.AddModelError(String.Empty, "Error while saving the album picture");
                    }
                } catch {
                    ModelState.AddModelError(String.Empty, "Error while saving the album to the database");
                }
            }
        }