递归方法。
//
/// TreeView数据绑定
///
///
protected void CreateTreeView()
{
TreeNode rootNode = new TreeNode();
rootNode.Text = "全部";
rootNode.Value = "-1";
BasicTypeTreeView.Nodes.Add(rootNode);
BasicInformationManager BasicManager = new BasicInformationManager();
var tlist = BasicManager.GetAllBasicInfoTypes();
foreach (Model.BasicInforType mtype in tlist)
{
if (mtype.ParentID == 0)
{
TreeNode Node = new TreeNode();
//添加根节点
Node.Text = mtype.BasicTypeName;
Node.Value = mtype.ID.ToString();
Node.ToolTip = "编码" + mtype.BasicCode;
getSubNode(ref Node, mtype.ID);
rootNode.ChildNodes.Add(Node);
}
}
}