2005下treeview 就不行
错误:
“System.Web.UI.WebControls.TreeNode”并不包含“Nodes”的定义
代码:
public void AddTree(int ParentID,TreeNode pNode)
{
DataSet ds=(DataSet)this.ViewState[ "ds "];
DataView dvTree=new DataView(ds.Tables[0]);
dvTree.RowFilter= "[id]= "+ParentID;
foreach(DataRowView row in dvTree)
{
TreeNode Node=new TreeNode();
if(pNode==null)
{
Node.Text=row[ "class "].ToString();
TreeView1.Nodes.Add(Node);
Node.Expanded=true;
AddTree(int.Parse(row[ "ID "].ToString()),Node);
}
else
{
Node.Text=row[ "Context "].ToString();
// Node.NavigateUrl= "kclist.aspx?id= " +HttpUtility.UrlEncode(row[ "Context "].ToString());
Node.Target= "main ";
pNode.Nodes.Add(Node);
Node.Expanded=true;
AddTree(int.Parse(row[ "ID "].ToString()),Node);
}
}
}
------解决方案--------------------pNode.Nodes改成pNode.ChildNodes
------解决方案--------------------pNode.Nodes.Add(Node);
改成->
pNode.ChildNodes.Add(Node);
------解决方案--------------------pNode.Nodes.Add(Node);
改成->
pNode.ChildNodes.Add(Node);
------解决方案------