Exemple #1
0
    /// <summary>
    /// Binds the data.
    /// </summary>
    private void BindData()
    {
        NameValueCollection history = StoreHelper.GetBrowseHistory();
        //StringCollection history = (StringCollection)Profile["EntryHistory"];

        List <Entry> entries = new List <Entry>();

        string[] values = history.GetValues("Entries");

        if (values != null)
        {
            bool isFirst = true;
            foreach (string key in values)
            {
                // Is it a first item? skip
                if (isFirst)
                {
                    isFirst = false;
                    continue;
                }

                if (!String.IsNullOrEmpty(key))
                {
                    Entry entry = CatalogContext.Current.GetCatalogEntry(key);
                    if (entry != null)
                    {
                        entries.Add(entry);
                    }
                }
            }
        }

        // Remove last history element, since it will be currently displayed item
        //if (entries.Count > 0)
        //    entries.RemoveAt(entries.Count - 1);

        if (entries.Count == 0)
        {
            this.Visible = false;
            return;
        }

        RecentlyViewedList.DataSource = entries.ToArray();
        RecentlyViewedList.DataBind();
    }