0

私は C#.Net の TreeView コンセプトで作業しています。私のシナリオはこのようなものです.私はルート名を持っています. それを拡張すると、名前が 2 つになります。名前を展開すると、その中に 2 つのサブネームが含まれます。

 foreach (DataRow masterRow in ds.Tables[0].Rows)
            {
                TreeNode masterNode = new TreeNode((string)masterRow["NAME"], Convert.ToString(masterRow["PARENT_ID"]));
                TreeView1.Nodes.Add(masterNode);

                foreach (DataRow childRow in masterRow.GetChildRows("Children"))
                {
                    TreeNode childNode = new TreeNode((string)childRow["NAME"], Convert.ToString(childRow["PARENT_ID"]));
                    masterNode.ChildNodes.Add(childNode);
                    childNode.Value = Convert.ToString(childRow["PARENT_ID"]);

                    foreach (DataRow masterRow1 in ds1.Tables[0].Rows)
                    {
                        TreeNode masterNode1 = new TreeNode((string)masterRow1["NAME"], Convert.ToString(masterRow1["PARENT_ID"]));
                        TreeView1.Nodes.Add(masterNode1);
                        {
                            foreach (DataRow childRow2 in masterRow1.GetChildRows("Children1"))
                            {
                                TreeNode childNode2 = new TreeNode((string)childRow2["NAME"], Convert.ToString(childRow2["PARENT_ID"]));
                                masterNode1.ChildNodes.Add(childNode2);
                                childNode2.Value = Convert.ToString(childRow2["PARENT_ID"]);
                            }
                        }
                    }
                }
            }

しかし、それは適切に機能していません。どこで間違ったのかわかりません..親切に私を導いてください..

4

0 に答える 0