TreeView2.Nodes.Clear();
KeyWordDataContext db = new KeyWordDataContext();
var L1 = from LL1 in db.ProductCategoryL1
select LL1;
foreach (var LQ1 in L1)
{
TreeNode x = new TreeNode(LQ1.CategoryL1Name);
this.TreeView2.Nodes.Add(x);
var LL2 = from L2 in db.ProductCategoryL2
where L2.CategoryL1ID == LQ1.CategoryL1ID
select L2;
foreach (var LQ2 in LL2)
{
TreeNode x1 = new TreeNode(LQ2.CategoryL2Name);
x.ChildNodes.Add(x1);
var LL3 = from L3 in db.ProductCategoryL3
where L3.CategoryL2ID == LQ2.CategoryL2ID
select L3.CategoryL3Name;
foreach (var item1 in LL3)
{
TreeNode x2 = new TreeNode(item1);
x1.ChildNodes.Add(x2);
}
}
}
0 留言