private void BtnShowRelatedItemClick(object sender, EventArgs e) { divRelatedLinks.Visible = true; Article[] related = VersionInfoObject.GetRelatedArticles(PortalId); if (related.Length == 0) { //what to do? } else { lstItems.DataSource = related; lstItems.DataBind(); } }
private void Page_Load(object sender, EventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } try { btnShowRelatedItem.Visible = false; divRelatedLinks.Visible = false; var related = new List <Article>(VersionInfoObject.GetRelatedArticles(PortalId)); ItemVersionSetting parentRelationshipSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "ArticleSettings", "IncludeParentCategoryArticles", PortalId); if (parentRelationshipSetting != null && Convert.ToBoolean(parentRelationshipSetting.PropertyValue, CultureInfo.InvariantCulture)) { int parentCategoryId = Category.GetParentCategory(VersionInfoObject.ItemId, PortalId); if (parentCategoryId > 0) { //get all articles in the same category, then removes this current article from that list. BD List <Article> categoryArticles = Category.GetCategoryArticles(parentCategoryId, PortalId); categoryArticles.RemoveAll(a => a.ItemId == VersionInfoObject.ItemId); related.AddRange(categoryArticles); } } if (related.Count < 1) { btnShowRelatedItem.Visible = false; divRelatedLinks.Visible = false; LinksPopulated = false; } else { lstItems.DataSource = related; lstItems.DataBind(); divRelatedLinks.Visible = true; LinksPopulated = true; } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }