private void GetCategories(TreeNode TNN) { // Fill child categories for certain Parent .. and loop inside it to bind all leafs under it. ProductCategories objCat = new ProductCategories(); TreeNode TN = new TreeNode(); DataTable dt = objCat.GetSubCategories(Int32.Parse(TNN.Value)); foreach (DataRow dr in dt.Rows) { TN = new TreeNode(dr[ProductCategories.ColumnNames.NameEn].ToString(), dr[ProductCategories.ColumnNames.ProductCategoryID].ToString(), "", "products.aspx?cid=" + dr[ProductCategories.ColumnNames.ProductCategoryID].ToString(), ""); TN.SelectAction = TreeNodeSelectAction.Expand; //TN.Expanded = true; TNN.ChildNodes.Add(TN); GetCategories(TN); } }
public string GetAllSubCats(int CategoryID) { string subcats = ""; ProductCategories subcat = new ProductCategories(); DataTable dt = subcat.GetSubCategories(CategoryID); foreach (DataRow dr in dt.Rows) { ProductCategories ch = new ProductCategories(); DataTable children = ch.GetSubCategories(Convert.ToInt32(dr[ProductCategories.ColumnNames.ProductCategoryID])); if (children.Rows.Count > 0) { subcats += "," + dr["ProductCategoryID"].ToString() + GetAllSubCats(Convert.ToInt32(dr[ProductCategories.ColumnNames.ProductCategoryID])); } else subcats += "," + dr["ProductCategoryID"].ToString(); } return subcats; }