private void LoadTopNavigation() { Item[] subitems = this.DataSourceItem.Axes.SelectItems(string.Format("./*[@@templateid = '{0}']", TemplateIds.Page)); List<NavigationElement> navigationElements = new List<NavigationElement>(); if (subitems != null) { foreach (Item item in subitems) { NavigationElement element = new NavigationElement { NavigationTitle = item.Fields["Navigation Title"].Value, NavigationUrl = LinkManager.GetItemUrl(item), Item = item }; navigationElements.Add(element); } } this.repTopNavigation.DataSource = navigationElements; this.repTopNavigation.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { List<NavigationElement> navigationElements = new List<NavigationElement>(); NewsSearcher searcher = new NewsSearcher(); Item[] searchResults = searcher.Search(IndexName, new string[] { "{0EB2F38A-FA48-433E-B6C2-E183E64A9E1C}".ToLower() }, MaxEntries); foreach (Item item in searchResults) { string navigationTitle = item.Fields["Headline"].Value; if (!string.IsNullOrEmpty(item.Fields["Publish Date"].Value)) { navigationTitle = DateUtil.FormatIsoDate(item.Fields["Publish Date"].Value, "d") + ": " + item.Fields["Headline"].Value; } NavigationElement element = new NavigationElement { NavigationTitle = navigationTitle, NavigationUrl = LinkManager.GetItemUrl(item) }; navigationElements.Add(element); } this.repNewsEntries.DataSource = navigationElements; this.repNewsEntries.DataBind(); }