protected void Page_Load(object sender, EventArgs e)
{
TreeNode root = new TreeNode("河北软件职业技术学院","0");//定义一个根节点
root.NavigateUrl = "http://www.hbsi.com.cn/";
TreeNode softdipartment = new TreeNode("软件工程系", "1001");
softdipartment.NavigateUrl = "http://221.192.237.88:8001/rjx";
root.ChildNodes.Add(softdipartment);//将子节点添加到父节点中
TreeNode netdirection = new TreeNode("net","1002");
netdirection.NavigateUrl = "http://221.192.237.88:8001/rjx/newsDetails/294/8/0.html";
softdipartment.ChildNodes.Add(netdirection);//将子节点添加到父节(softdipartment)点中
this.TreeView1.Nodes.Add(root);//将根节点添加到treeview中(就将根节点及子节点都装到了treeview中)
}
也可以在设计界面编辑节点;