private void BuildCategoriesPath()
    {
        this.cellCategoriesPath.InnerText = "";
        SRL_Category category = this.Categories.SingleOrDefault(cat => cat.CategoryId == this.CategoryId);

        while (category != null)
        {
            LinkButton btnCat = new LinkButton();
            btnCat.Text = category.CategoryName;
            btnCat.Attributes["CategoryId"] = category.CategoryId.ToString();
            btnCat.Click += new EventHandler(this.btnSelectCategory_Click);

            this.cellCategoriesPath.Controls.AddAt(0, btnCat);

            Literal ltr = new Literal();
            ltr.Text = " >> ";
            this.cellCategoriesPath.Controls.AddAt(0, ltr);

            category = this.Categories.SingleOrDefault(cat => cat.CategoryId == category.ParentCategoryId);
        }

        LinkButton btnRoot = new LinkButton();

        btnRoot.Text = MyGlobalResources.All;
        btnRoot.Attributes["CategoryId"] = "0";
        btnRoot.Click += new EventHandler(this.btnSelectCategory_Click);
        this.cellCategoriesPath.Controls.AddAt(0, btnRoot);
    }
    protected void rptCategories_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        SRL_Category category = e.Item.DataItem as SRL_Category;

        if (category != null)
        {
            LinkButton btn = e.Item.FindControl("btnCategory") as LinkButton;
            btn.Text += " (" + category.RecipesCount + ")";
        }
    }
Exemplo n.º 3
0
    protected void rptCategories_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        SRL_Category category = e.Item.DataItem as SRL_Category;

        if (category != null)
        {
            //LinkButton btn = e.Item.FindControl("btnCategory") as LinkButton;
            //btn.Text += " (" + category.RecipesCount + ")";
            HyperLink lnk = (HyperLink)e.Item.FindControl("lnkCategory");
            lnk.Text        = string.Format("{0} ({1})", category.CategoryName, category.RecipesCount);
            lnk.NavigateUrl = string.Format(this.RecipeCategoryChangeBaseUrl, category.CategoryId);
        }
    }
 public SRL_Category(int categoryId, string categoryName, SRL_Category parent)
 {
     this.CategoryId     = categoryId;
     this.CategoryName   = categoryName;
     this.ParentCategory = parent;
 }