protected void rptrLatestPosts_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var forumPost = e.Item.DataItem as ForumPost; var hlTopic = e.Item.FindControl("hlTopic") as HyperLink; if (hlTopic != null) { ForumTopic forumTopic = forumPost.Topic; if (forumTopic != null) { hlTopic.Text = Server.HtmlEncode(forumTopic.Subject); hlTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumPost.TopicId); } } var lblPosted = e.Item.FindControl("lblPosted") as Label; if (lblPosted != null) { lblPosted.Text = DateTimeHelper.ConvertToUserTime(forumPost.CreatedOn).ToString("f"); } var lblPost = e.Item.FindControl("lblPost") as Label; if (lblPost != null) { lblPost.Text = ForumManager.FormatPostText(forumPost.Text); } } }
protected void gvLP_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ForumPost forumPost = (ForumPost)e.Row.DataItem; HyperLink hlTopic = e.Row.FindControl("hlTopic") as HyperLink; if (hlTopic != null) { ForumTopic forumTopic = forumPost.Topic; if (forumTopic != null) { hlTopic.Text = Server.HtmlEncode(forumTopic.Subject); hlTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumPost.TopicId); } } Label lblPosted = e.Row.FindControl("lblPosted") as Label; if (lblPosted != null) { lblPosted.Text = DateTimeHelper.ConvertToUserTime(forumPost.CreatedOn, DateTimeKind.Utc).ToString("f"); } Label lblPost = e.Row.FindControl("lblPost") as Label; if (lblPost != null) { lblPost.Text = ForumManager.FormatPostText(forumPost.Text); } } }
public void BindData() { if (forumPost != null) { lAnchor.Text = string.Format("<a name=\"{0}\"></a>", forumPost.ForumPostID); btnEdit.Visible = ForumManager.IsUserAllowedToEditPost(NopContext.Current.User, forumPost); btnDelete.Visible = ForumManager.IsUserAllowedToDeletePost(NopContext.Current.User, forumPost); lblDate.Text = DateTimeHelper.ConvertToUserTime(forumPost.CreatedOn).ToString("f"); lblText.Text = ForumManager.FormatPostText(forumPost.Text); lblForumPostID.Text = forumPost.ForumPostID.ToString(); Customer customer = forumPost.User; if (customer != null) { if (CustomerManager.AllowViewingProfiles) { hlUser.Text = Server.HtmlEncode(CustomerManager.FormatUserName(customer)); hlUser.NavigateUrl = SEOHelper.GetUserProfileURL(customer.CustomerID); lblUser.Visible = false; } else { lblUser.Text = Server.HtmlEncode(CustomerManager.FormatUserName(customer)); hlUser.Visible = false; } if (CustomerManager.AllowCustomersToUploadAvatars) { Picture customerAvatar = customer.Avatar; int avatarSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85); if (customerAvatar != null) { string pictureUrl = PictureManager.GetPictureUrl(customerAvatar, avatarSize, false); this.imgAvatar.ImageUrl = pictureUrl; } else { if (CustomerManager.DefaultAvatarEnabled) { string pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize); this.imgAvatar.ImageUrl = pictureUrl; } else { imgAvatar.Visible = false; } } } else { imgAvatar.Visible = false; } if (customer.IsForumModerator) { lblStatus.Text = GetLocaleResourceString("Forum.Moderator"); } else { phStatus.Visible = false; } if (ForumManager.ShowCustomersPostCount) { lblTotalPosts.Text = customer.TotalForumPosts.ToString(); } else { phTotalPosts.Visible = false; } if (CustomerManager.ShowCustomersJoinDate) { lblJoined.Text = DateTimeHelper.ConvertToUserTime(customer.RegistrationDate).ToString("d"); } else { phJoined.Visible = false; } if (CustomerManager.ShowCustomersLocation) { Country country = CountryManager.GetCountryByID(customer.CountryID); if (country != null) { lblLocation.Text = Server.HtmlEncode(country.Name); } else { phLocation.Visible = false; } } else { phLocation.Visible = false; } if (ForumManager.AllowPrivateMessages) { if (customer != null && !customer.IsGuest) { btnSendPM.CustomerID = customer.CustomerID; phPM.Visible = true; } else { phPM.Visible = false; } } else { phPM.Visible = false; } if (ForumManager.SignaturesEnabled && !String.IsNullOrEmpty(customer.Signature)) { lblSignature.Text = ForumManager.FormatSignatureText(customer.Signature); } else { pnlSignature.Visible = false; } } else { //error, cannot be } } }