/// <summary> /// Binds the data. /// </summary> private void BindData() { List<Photo> photos = new PhotoLogic().RetrievePhotosByGalleryId(galleryId); photoRepeater.DataSource = photos; photoRepeater.DataBind(); }
/// <summary> /// Gets the random photo from gallery. /// </summary> /// <param name="imageLiteral">The image literal.</param> /// <param name="imagePanel">The image panel.</param> private void GetRandomPhotoFromGallery(ITextControl imageLiteral, WebControl imagePanel) { //retrieve random photo by gallery Photo randomPhoto = new PhotoLogic().RetrieveRandomPhotoByGalleryId(gallery.GalleryId); const string imageLinkFormat = "<a href=\"?gid={0}\" title=\"{1}\" ><img title=\"{1}\" alt=\"{1}\" src=\"GalleryImage.ashx?t={2}\" /></a>"; //Get handle on literal imageLiteral.Text = string.Format(imageLinkFormat, gallery.GalleryId, gallery.Name, randomPhoto.PhotoID); imagePanel.CssClass = (randomPhoto.Profile == PhotoProfile.Landscape ? "landscapelandingimage" : "landscapelandingimage"); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { //Retrieve settings and set the site title. GallerySettings settings = GallerySettings.Load(); Page.Title = settings.GalleryTitle; Photo photo = new PhotoLogic().RetrieveLastestPhoto(); //If no title, then don't render title control if (!string.IsNullOrEmpty(photo.Title)) { imageTitle.Text = photo.Title; imageTitle.Visible = true; } //populate the WebForm controls. image.ImageUrl = "GalleryImage.ashx?f=" + photo.PhotoID; image.AlternateText = photo.Title; description.Text = photo.Description; }
/// <summary> /// Handles the ItemDataBound event of the galleryViewRepeater control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param> protected void galleryViewRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Gallery gallery = (Gallery)e.Item.DataItem; //retrieve random photo by gallery Photo randomPhoto = new PhotoLogic().RetrieveRandomPhotoByGalleryId(gallery.GalleryId); const string imageLinkFormat = "<a href=\"?lgid={0}\" title=\"{1}\" ><img title=\"{1}\" alt=\"{1}\" src=\"GalleryImage.ashx?t={2}\" /></a>"; //Get handle on literal Literal imageHtml = (Literal)e.Item.FindControl("imageLiteral"); imageHtml.Text = string.Format(imageLinkFormat, gallery.GalleryId, gallery.Name, randomPhoto.PhotoID); //Set Gallery title Literal galleryTitle = (Literal)e.Item.FindControl("titleLiteral"); galleryTitle.Text = gallery.Name; //Set Gallery photo count Literal photoCount = (Literal)e.Item.FindControl("photoCount"); photoCount.Text = gallery.PhotoCount + (gallery.PhotoCount == 1 ? " Photo" : " Photos"); } }