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

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

博客园 - Machine Lee

js动态更换img的src问题 两台服务器上SQL Server数据库数据互操作示例 JQuery应用集合 SVN自动更新测试服务器工作副本(C#写winform程序实现) 学习《SQL Server 2005管理员大全》时遇到的困难 ASP.NET根据URL生成网页缩略图示例程序(C#语言) 传参防SQL注入函数 web.config中sessionState节点的配置方案 SQL中DateTime转换成Varchar样式 ASP错误信息提示函数 - Machine Lee - 博客园 ASP操作Excel技术总结[转载收藏] js控制文本框只能输入整数或浮点数 正则表达式验证可发短信的号码,如手机号和小灵通号码(106+区号+号码) SQL中实现Split的功能函数 GridView中CheckBox客户端全选 验证多行文本框输入长度的正则表达式 TreeView动态构造多级树并实现拖动(收藏) javascript写的日历控件(收藏) javascript获取TreeView控件选中节点的Text和Value
TreeView绑定XML数据源C#代码示例
Machine Lee · 2009-05-11 · via 博客园 - Machine Lee

    private void BindTreeView()
    {
        UnitInfo bUnitInfo = new UnitInfo();
        DataSet ds = bUnitInfo.GetUnitInfo();
        if (ds != null && ds.Tables[0].Rows.Count > 0)
        {
            bool HasAddedLast = true; ;
            string strDs = "<?xml version='1.0' encoding='GB2312'?>";
            for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
            {
                strDs += "<a Name='" + ds.Tables[0].Rows[i-1][1].ToString() + "' TID='" + ds.Tables[0].Rows[i-1][0].ToString() + "'>";
                for (int j = i; j < ds.Tables[0].Rows.Count; j++)
                {
                    i = j;
                    if (ds.Tables[0].Rows[j-1]["Path"].ToString().Length == ds.Tables[0].Rows[j]["Path"].ToString().Length)
                    {
                        strDs += "</a><a Name='" + ds.Tables[0].Rows[j][1].ToString() + "' TID='" + ds.Tables[0].Rows[j][0].ToString() + "'>";
                    }
                    else if (ds.Tables[0].Rows[j -1]["Path"].ToString().Length < ds.Tables[0].Rows[j]["Path"].ToString().Length)
                    {
                        strDs += "<a Name='" + ds.Tables[0].Rows[j][1].ToString() + "' TID='" + ds.Tables[0].Rows[j][0].ToString() + "'>";
                    }
                    else
                    {
                        if (i==ds.Tables[0].Rows.Count-1)
                        {
                            HasAddedLast = false;
                        }
                        break;
                    }
                }
                int nCount = 0;
                nCount = System.Math.Abs(ds.Tables[0].Rows[i - 1]["Path"].ToString().Length - ds.Tables[0].Rows[i]["Path"].ToString().Length) / 5 + 1;
                for (int j = 0; j < nCount; j++)
                {
                    strDs += "</a>";
                }
                if ((i == ds.Tables[0].Rows.Count - 1) && HasAddedLast==false)
                {
                    strDs += strDs += "<a Name='" + ds.Tables[0].Rows[i][1].ToString() + "' TID='" + ds.Tables[0].Rows[i][0].ToString() + "'>";
                    for (int k = 0; k < (ds.Tables[0].Rows[i]["Path"].ToString().Length/5-1); k++)
                    {
                        strDs += "</a>";
                    }
                }
            }
            strDs += "</a>";
            XmlDataSource xds = new XmlDataSource();
            xds.ID = "XDS";
            xds.Data = strDs;
            TreeView1.DataSource = xds;
            TreeView1.DataBind();
        }
    }

这个算法没有经过大量数据的检验,有待考证!