public void rptFiles_ItemDataBound(object sender, RepeaterItemEventArgs e) { var redirectionUrl = (RedirectionUrl)e.Item.DataItem; var downloadUrl = UrlHelper.GetUrlFromSection(RedirectionModule.Section) + "/redirect/" + redirectionUrl.Id; var hplFileImg = (HyperLink)e.Item.FindControl("hplFileImg"); hplFileImg.NavigateUrl = downloadUrl; hplFileImg.ImageUrl = base.Page.ResolveUrl("~/Modules/Downloads/Images/" + FileTypesMap.GetIconFilename(System.IO.Path.GetExtension(redirectionUrl.Url))); var hplFile = (HyperLink)e.Item.FindControl("hplFile"); hplFile.NavigateUrl = downloadUrl; var lblDateModified = (Label)e.Item.FindControl("lblDateModified"); lblDateModified.Text = TimeZoneUtil.AdjustDateToUserTimeZone( redirectionUrl.DatePublished, this.Page.User.Identity).ToString(); var lblPublisher = (Label)e.Item.FindControl("lblPublisher"); lblPublisher.Text += " Published at " + redirectionUrl.Publisher.FullName; var lblNumberOfDownloads = (Label)e.Item.FindControl("lblNumberOfDownloads"); lblNumberOfDownloads.Text += "Downloads: " + redirectionUrl.NumberOfDownloads; }
private void rptFiles_ItemDataBound(object sender, RepeaterItemEventArgs e) { FileResource file = e.Item.DataItem as FileResource; if (file != null && file.IsViewAllowed(base.Page.User)) { string downloadUrl = file.GetContentUrl(); string fileDetails = file.FileName + " (" + file.Length + " bytes)"; HyperLink hplFileImg = e.Item.FindControl("hplFileImg") as HyperLink; hplFileImg.NavigateUrl = downloadUrl; hplFileImg.ImageUrl = base.Page.ResolveUrl("~/Modules/Downloads/Images/" + FileTypesMap.GetIconFilename(Path.GetExtension(file.FileName))); hplFileImg.Text = fileDetails; HyperLink hplFile = e.Item.FindControl("hplFile") as HyperLink; hplFile.NavigateUrl = downloadUrl; hplFile.ToolTip = fileDetails; Panel pnlFileDetails = e.Item.FindControl("pnlFileDetails") as Panel; pnlFileDetails.Visible = (this.Module.ShowDateModified || this.Module.ShowPublisher || this.Module.ShowNumberOfDownloads); if (this.Module.ShowDateModified) { Label lblDateModified = e.Item.FindControl("lblDateModified") as Label; lblDateModified.Visible = true; lblDateModified.Text = TimeZoneUtil.AdjustDateToUserTimeZone( file.PublishedAt.Value, this.Page.User.Identity).ToString(); } if (this.Module.ShowPublisher) { Label lblPublisher = e.Item.FindControl("lblPublisher") as Label; lblPublisher.Visible = true; lblPublisher.Text += base.GetText("PUBLISHEDBY") + " " + file.ModifiedBy.FullName; } if (this.Module.ShowNumberOfDownloads) { Label lblNumberOfDownloads = e.Item.FindControl("lblNumberOfDownloads") as Label; lblNumberOfDownloads.Visible = true; lblNumberOfDownloads.Text += base.GetText("NUMBEROFDOWNLOADS") + ": " + file.DownloadCount; } } else { e.Item.Visible = false; } }