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

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
G
Google Developers Blog
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
V
Visual Studio Blog
博客园 - Franky
S
SegmentFault 最新的问题
Jina AI
Jina AI
爱范儿
爱范儿
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
C
Check Point Blog
月光博客
月光博客
P
Proofpoint News Feed
T
The Blog of Author Tim Ferriss
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MongoDB | Blog
MongoDB | Blog
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
Martin Fowler
Martin Fowler

博客园 - Sunny

开发人员一定要加入收藏夹的网站(转载) 我写的一个小程序 tabs研究 dotnetnuke( modules /tabs )权限研究 数据库知识2 数据库学习1 asp.net缓存、企业程序库缓存及格式化日期 - Sunny - 博客园 可爱的外甥女 dotnetnuke 里profile 的使用 怎样写自己的ConfigurationHandler(DOTNETNUKE 研究)? 编写upload程序 多国技术总结 远程教育系统总结 项目(多国技术) 总结 页面验证码程序(C#) string与stringbuilder flyweigth享元设计模式与委托总结 dotnetnuke 本地化技术杂谈 怎样获取获取GridView里面的label
循环遍历一个控件方法
Sunny · 2006-04-05 · via 博客园 - Sunny

        public static StringBuilder RecursiveControl(Control ct)
        {
            StringBuilder sb 
= new StringBuilder();
            RecursiveControl(ct, 
0 ,sb);
            
return sb;
        }
public static void RecursiveControl(Control ct,int xc,StringBuilder sb)
        {
            xc
++;
            
            
if (ct != null)
            {
                
for (int i = 0; i < ct.Controls.Count; i++)
                {
                    
for (int j = 1; j < xc; j++)
                    {
                        sb.Append(
"-");
                    }
                    sb.Append(ct.Controls[i].ToString());
                    sb.Append(
"<br/>");
                    RecursiveControl(ct.Controls[i],xc,sb);
                }
            }
            
        }

调用方法:

        StringBuilder sb = SharedClass.RecursiveControl(DataList1);
        Response.Write(sb.ToString());