Beispiel #1
0
    private void GetCategories()
    {
        cats = new CategoryController().GetCachedCategories();

        var parents = cats.FindAll(
            delegate(Category c) { return(c.ParentId >= 0); });

        if (cats != null && cats.Count > 0)
        {
            Category_List.Visible = true;


            CategoryCollection source = new CategoryController().GetTopLevelCachedCategories();
            source.Sort(
                delegate(Category c, Category c1) { return(c.Name.CompareTo(c1.Name)); });

            Categories_List.DataSource     = source;
            Categories_List.ItemDataBound += Categories_List_ItemDataBound;
            Categories_List.DataBind();
        }
        else
        {
            Category_List.Visible = false;
        }
    }
Beispiel #2
0
    protected void Categories_List_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Category cat = (Category)e.Item.DataItem;

            var children = cats.FindAll(
                delegate(Category c) { return(c.ParentId == cat.Id); });
            if (children != null && children.Count > 0)
            {
                // reset the child index counter
                currentChildIndex = 0;

                Repeater c = (Repeater)e.Item.FindControl("NestedCategoriesList");
                c.ItemDataBound += NestedCategoriesList_ItemDataBound;
                c.DataSource     = children;
                c.DataBind();
            }
        }
    }
Beispiel #3
0
    private void GetCategories()
    {
        cats = new CategoryController().GetCachedCategories();

            List<Category> parents = (List<Category>)cats.FindAll(
                                                        delegate(Category c)
                                                        {
                                                            return c.ParentId >= 0;
                                                        });

            if (cats != null && cats.Count > 0)
            {
                Category_List.Visible = true;

                CategoryCollection source = new CategoryController().GetTopLevelCachedCategories();
                source.Sort(
                    delegate(Category c, Category c1)
                    {
                        return c.Name.CompareTo(c1.Name);
                    });

                Categories_List.DataSource = source;
                Categories_List.ItemDataBound += new RepeaterItemEventHandler(Categories_List_ItemDataBound);
                Categories_List.DataBind();
            }
            else
            {
                Category_List.Visible = false;
            }
    }