/// <summary> /// Handles the ItemDataBound event of the lvSearchResults control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ListViewItemEventArgs"/> instance containing the event data.</param> protected void lvSearchResults_ItemDataBound(object sender, ListViewItemEventArgs e) { dynamic userData = (dynamic)e.Item.DataItem; ImageDisplay userThumbDisplay = (ImageDisplay)e.Item.FindControl("userThumbDisplay"); userThumbDisplay.DocumentMediaId = (int)userData.DocumentMediaId; LinkButton lnkbtnUser = (LinkButton)e.Item.FindControl("lnkbtnUser"); Literal ltrlUsername = (Literal)e.Item.FindControl("ltrlUsername"); string userFullName = (userData.User.FirstName + " " + userData.User.LastName).Trim(); ltrlUsername.Text = Support.TruncateString(userFullName, 15); if (userFullName.Length > 15) { lnkbtnUser.ToolTip = userFullName; } }
/// <summary> /// Handles the ItemDataBound event of the lvAttachments control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ListViewItemEventArgs"/> instance containing the event data.</param> protected void lvAttachments_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { dynamic media = e.Item.DataItem as dynamic; if (media.FileExtension == "HYPERLINK")//If it is a hyperlink,load hyperlink specific content. { HtmlGenericControl divDocAttachments = (HtmlGenericControl)e.Item.FindControl("divDocAttachments"); divDocAttachments.Visible = false; HtmlGenericControl divLinks = (HtmlGenericControl)e.Item.FindControl("divLinks"); divLinks.Visible = true; HtmlAnchor link = (HtmlAnchor)e.Item.FindControl("lblLinkURL"); LinkButton hyperlinkButton = (LinkButton)e.Item.FindControl("HyperLinkLinkButton"); hyperlinkButton.Enabled = !IsReadOnly; hyperlinkButton.CommandArgument = media.DocumentMediaId.ToString(); string labelTxt = string.Empty; if (media.Name != null && media.Name != string.Empty) { labelTxt = media.Name; link.HRef = media.Description; } else { labelTxt = media.Description; link.HRef = media.Description; } Label lblType = (Label)e.Item.FindControl("lblType"); Label lblLinkedDate = (Label)e.Item.FindControl("lblLinkedDate"); Label lblLinkedBy = (Label)e.Item.FindControl("lblLinkedBy"); HtmlGenericControl divDescription = (HtmlGenericControl)e.Item.FindControl("divDescription"); HtmlGenericControl divLinkBlock = (HtmlGenericControl)e.Item.FindControl("divLinkBlock"); HtmlGenericControl extraLinkDetails = (HtmlGenericControl)e.Item.FindControl("extraLinkDetails"); switch (Mode) //Display and hide extra fields based on the mode { case DisplayMode.ItemBrief: link.InnerText = Support.TruncateString(labelTxt, 60); link.Title = labelTxt; extraLinkDetails.Visible = false; divDescription.Visible = true; break; case DisplayMode.Project: extraLinkDetails.Visible = true; link.InnerText = Support.TruncateString(labelTxt, 30); link.Title = labelTxt; lblLinkedDate.Text = string.Concat("Uploaded: ", Utils.FormatDate(media.LastUpdatedDate)); lblLinkedBy.Text = Support.TruncateString(string.Concat("By: ", media.LastUpdatedBy), 35); divDescription.Visible = false; divLinks.Style.Add("Width", "400px"); divLinkBlock.Style.Add("Width", "200px"); break; } } else { ImageDisplay thumbAttachment = (ImageDisplay)e.Item.FindControl("thumbAttachment"); thumbAttachment.ImageTitle = media.Name; thumbAttachment.DocumentMediaId = media.DocumentMediaId; thumbAttachment.IsThumbnail = true; LinkButton lnkbtnAttachment = (LinkButton)e.Item.FindControl("lnkbtnAttachment"); lnkbtnAttachment.Enabled = false; lnkbtnAttachment.CommandArgument = media.DocumentMediaId.ToString(); Label lblAttachmentName = (Label)e.Item.FindControl("lblAttachmentName"); Literal litAttachmentType = (Literal)e.Item.FindControl("litAttachmentType"); litAttachmentType.Text = media.FileExtension; Label lblUploadedDate = (Label)e.Item.FindControl("lblUploadedDate"); Label lblUploadedBy = (Label)e.Item.FindControl("lblUploadedBy"); HtmlGenericControl divAttachmentBlock = (HtmlGenericControl)e.Item.FindControl("divAttachmentBlock"); HtmlGenericControl divDocAttachments = (HtmlGenericControl)e.Item.FindControl("divDocAttachments"); HtmlGenericControl extraDetails = (HtmlGenericControl)e.Item.FindControl("extraDetails"); switch (Mode) { case DisplayMode.ItemBrief: lblAttachmentName.Text = Support.TruncateString(media.Name, 50); if (!string.IsNullOrEmpty(media.Name) && media.Name.Length > 50) { lblAttachmentName.ToolTip = media.Name; } CheckBox chkInclude = (CheckBox)e.Item.FindControl("chkInclude"); chkInclude.Enabled = !IsReadOnly && this.GetBL <InventoryBL>().CanEditIteminItemBrief(RelatedId); if (media.SourceTable == "Item") { chkInclude.Enabled = false; chkInclude.ToolTip = "These attachments are connected to this Item in the Inventory so they cannot be changed or removed"; } chkInclude.Visible = IsItemAllreadyExist; chkInclude.Checked = media.ItemBriefItemDocumentMediaId > 0; thumbAttachment.FunctionPrefix = (media.SourceTable == "Item") ? "ReadOnlyModeDP" : "EditModeModeDP"; extraDetails.Visible = false; break; case DisplayMode.Project: lblAttachmentName.Text = Support.TruncateString(media.Name, 35); if (!string.IsNullOrEmpty(media.Name) && media.Name.Length > 35) { lblAttachmentName.ToolTip = media.Name; } divDocAttachments.Style.Add("Width", "400px"); divAttachmentBlock.Style.Add("Width", "200px"); HtmlGenericControl divCheckInclude = (HtmlGenericControl)e.Item.FindControl("divCheckInclude"); divCheckInclude.Visible = false; extraDetails.Visible = true; lblUploadedDate.Text = string.Concat("Uploaded: ", Utils.FormatDate(media.LastUpdatedDate)); lblUploadedBy.Text = Support.TruncateString(string.Concat("By: ", media.LastUpdatedBy), 35); thumbAttachment.FunctionPrefix = "EditModeModeDP"; break; } } } }