protected void BindTreeView()
        {
            rtvCatList.Nodes.Clear();
            ProductCategoryController ch = new ProductCategoryController();
            //ProductHelper ph = new ProductHelper();
            List <ProductCategory> dtParent = ch.GetCatParent();

            if (dtParent != null && dtParent.Count > 0)
            {
                foreach (ProductCategory dr in dtParent)
                {
                    RadTreeNode root = new RadTreeNode();
                    root.Text  = "<span style=\"font-weight:bold;font-size:14px;font-family:'Open Sans', sans-serif\">" + dr.Product_Category_Name + "</span>";
                    root.Value = dr.ID.ToString();
                    List <ProductCategory> dtChild = ch.GetCatChildren(dr.ID);
                    if (dtChild != null && dtChild.Count > 0)
                    {
                        foreach (ProductCategory drChild in dtChild)
                        {
                            // string itemCount = " (<span style='color:red; font-weight:bold'>" + ph.GetProductCountByCatID(drChild["Cat_ID"].ToString()) + "</span>)";
                            string      itemCount = "";
                            RadTreeNode child     = new RadTreeNode();
                            child.Text = "<span style=\"font-size:12px;font-family:'Open Sans', sans-serif\">" + drChild.Product_Category_Name +
                                         "</span>" + itemCount;
                            child.Value = drChild.ID.ToString();
                            List <ProductCategory> dtChildLevel3 = ch.GetCatChildren(drChild.ID);
                            if (dtChildLevel3 != null && dtChildLevel3.Count > 0)
                            {
                                foreach (ProductCategory drChildLevel3 in dtChildLevel3)
                                {
                                    string      itemCountLevel3 = "";
                                    RadTreeNode childLevel3     = new RadTreeNode();
                                    childLevel3.Text = "<span style=\"font-size:12px;font-family:'Open Sans', sans-serif\">" + drChildLevel3.Product_Category_Name +
                                                       "</span>" + itemCountLevel3;
                                    childLevel3.Value = drChildLevel3.ID.ToString();
                                    child.Nodes.Add(childLevel3);
                                }
                            }
                            root.Nodes.Add(child);
                        }
                    }

                    rtvCatList.Nodes.Add(root);
                }
                rtvCatList.ExpandAllNodes();
            }
        }
Ejemplo n.º 2
0
        private void BindData()
        {
            List <ProductCategory> dtParent = ch.GetCatParent();

            if (dtParent != null && dtParent.Any())
            {
                grvColor.DataSource = dtParent;
                grvColor.DataBind();
            }
            else
            {
                dtParent.Add(new ProductCategory(0, string.Empty, string.Empty, string.Empty, string.Empty, 0, false, 0, string.Empty, 0));
                grvColor.DataSource = dtParent;
                grvColor.DataBind();
                grvColor.Rows[0].Visible = false;
            }
        }