惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - Kenny田

iOS 下 Podfile 使用方法 使用 NVM 管理不同的 Node.js 版本 将React Native集成至Android原生应用 Gradle在Windows环境与Linux上配置有哪些不同? 学习Android Studio里的Gradle 解决 Android Studio 乱码问题 不知道如何处理的Windows Phone异常 用命令行安装并启动Windows Phone 8 App 在Windows Phone项目中调用C语言DLL 演示Microsoft Advertising SDK for Windows Phone 8.1 PLSQL Developer 初始化错误 [原]初次运用数据缓存机制 [原]执行存储过程后返回影响的行数 [原]可定义的英文小日历 可逆加密解密程序(ASP版) 全文服务(Microsoft 搜索)不可用。系统管理员必须启动此服务 [转]解决sql2000挂起无法安装的问题 [转]安装SQL Server 2000 时出现 command line option syntax error [原]如何将一个表中的某一列的数据全部复制到另一个表中
[原]有TreeNode”并不包含“Nodes”的定义困扰的朋友看过来
Kenny田 · 2008-06-08 · via 博客园 - Kenny田

  在用TreeView的时候可能会出现ystem.Web.UI.WebControls.TreeNode”并不包含“Nodes”的定义
  那是我们都用了类似下面的代码(我已经修正了错误)

  DataSet ds = null;
  
protected void Page_Load(object sender, EventArgs e)
  
{
    
if (!IsPostBack)
    
{
      
string sql = "select class_id,class_name,class_parentid from proclass";
      ds 
= KennyDataOp.GetDataSet(sql);
      AddTree(
0, (TreeNode)null"Product.aspx?cid=");
    }

  }

  
public void AddTree(int ParentID, TreeNode pNode,string urls)
  
{
    DataView dvTree 
= new DataView(ds.Tables[0]);
    
//过滤ParentID,得到当前的所有子节点
    dvTree.RowFilter = "[class_parentid] = " + ParentID;
    
foreach (DataRowView Row in dvTree)
    
{
      TreeNode Node 
= new TreeNode();
      
if (pNode == null)
      
{    //添加根节点
        Node.Text = Row["class_name"].ToString();
        Node.NavigateUrl 
= urls + Row["class_id"].ToString();
        
this.TreeView1.Nodes.Add(Node);
        Node.Expanded 
= true;
        AddTree(Int32.Parse(Row[
"class_id"].ToString()), Node, urls); //再次递归
      }

      
else
      
{  //添加当前节点的子节点
        Node.Text = Row["class_name"].ToString();
        Node.NavigateUrl 
= urls + Row["class_id"].ToString();
        pNode.ChildNodes.Add(Node);
        Node.Expanded 
= true;
        AddTree(Int32.Parse(Row[
"class_id"].ToString()), Node, urls); //再次递归
      }

    }

  }

倒数第三行代码是pNode.ChildNodes.Add(Node),Not pNode.Notes.Add(Node)

VS 2005 的TreeView控件有些更改, 只有TreeView下有Nodes集合, 而TreeNode下有ChildNodes集合