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

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
小众软件
小众软件
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tailwind CSS Blog
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
S
Secure Thoughts
O
OpenAI News
P
Proofpoint News Feed
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
T
Tenable Blog
A
Arctic Wolf
L
LINUX DO - 热门话题
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
博客园_首页
雷峰网
雷峰网
IT之家
IT之家
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
H
Heimdal Security Blog

博客园 - 思然

邮件带图片附件 - 思然 - 博客园 XML查找节点 - 思然 - 博客园 动态生成rdlc 报表(原创) 图片处理 - 思然 - 博客园 数据绑定及其他 - 思然 - 博客园 图片上传及网络相册功能 SQL Server 2005 Express 使用心得 - 思然 附加进程调试和存储过程调试 (转)DIV CSS布局教程:应用ul、li实现表格形式 用户控件的使用经验 缓存之缓存文件依赖及编程方式设置输出缓存过期 防刷新多次提交 枚举的应用 添加div符号注意符号问题 Datalist调用本地文件绑定图片 用户控件-TreeView的用法 关于javascript调用webservices的中文参数乱码的问题 服务器端和客户端清除TextBox控件的值 获取母版页的控件的方法
关于table控件的一个疑难问题(涉及循环)
思然 · 2007-07-16 · via 博客园 - 思然

我用的是Table控件,我有个需求Table每行显示10张图片,
我所有的图片已经封装在IList<string>imglist=new list<>();
首先我获取了有多少张图片并算出会有多少行
 //图片的数量
int count = imglist.Count;
//计算会有多少行
int rowCount = count % 10 > 0 ? count / 10 + 1 : count / 10;
接着代码如下
           //首先动态加载行
            for (int j = 0; j < rowCount;j++)
            {
                TableRow tr = new TableRow();
                Table1.Rows.Add(tr);
              
                for (int i = 0; i < count; i++)
                {
                    TableCell tc = new TableCell();
                    Image img = new Image();
                    img.ID = "img" + i.ToString();
                    img.Width = Convert.ToUInt16(100);
                    img.Height = Convert.ToUInt16(100);
                    img.Attributes.Add("onclick", "showimage(this)");
                    img.ImageUrl = path + "\\" + imglist[i].ToString();
                    tc.Controls.Add(img);
                    tr.Cells.Add(tc);
                }
            }
我图片总共有12张,我希望达到的效果是第一行显示10条,第二行显示2条。结果两行都显示的是前10条.我知道我的循环有问题但不知道应该怎样解决~

posted @ 2007-07-16 15:34  思然  阅读(266)  评论()    收藏  举报