写了一个TreeView从数据库中获取node。一开始,添加数据后TreeView能够从中获取并成功添加node。但随着数据的增加(约同一层上有了5、6个node),之前添加的node却不见了,或者之前的node的childnode不见了。之前添加的数据绝对没有变动过。实在费解。开始时:
--A
|
+ --- A_1
| |
| ---A_1_1
|
|-----A_2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
出现问题:
--A
|
+---A_1
|
|
|
|---A_2
|
|
|
|---A_3
| |
| ---A_3_1
|
|---A_4
|
|
|
|---A_5~~~~~~~~~~~~~~~~~~~~~~~ 奇怪:A_1的childnode A_1_2 不见了(没有加载?不可能吧)
--A
|
+ --- A_1
| |
| ---A_1_1
|
|-----A_2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
出现问题:
--A
|
+---A_1
|
|
|
|---A_2
|
|
|
|---A_3
| |
| ---A_3_1
|
|---A_4
|
|
|
|---A_5~~~~~~~~~~~~~~~~~~~~~~~ 奇怪:A_1的childnode A_1_2 不见了(没有加载?不可能吧)
{
//获得是childnode的数据行
DataRow[] myDataRows = allNodeTable.Select("Parent_ID = "+parent_ID);
//添加childnode
foreach(DataRow myDataRow in myDataRows)
{
TreeNode myTableNode=new TreeNode();
myTableNode.ID=myDataRow["Object_ID"].ToString();
myTableNode.Text=myDataRow["Name"].ToString();
if (ParentNode != null)
ParentNode.Nodes.Add(myTableNode);
else
myTreeView.Nodes.Add(myTableNode);
//递归调用Tree_Load
this.Tree_Load(allNodeTable,myDataRow["Object_ID"].ToString(),myTreeView,myTableNode);
}
}
我没仔细考虑,但上面一句好像是无条件的无限递归下去