请问如何遍历Repeater 中 Panel 中的TextBox? 请问如何遍历Repeater 中 Panel 中的TextBox?谢谢大家!呵呵 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 for(int i=0;i<Repeater1.Item.Count;i++){ Panel p=(Panel)Repeater1.Item[i].FindControl("Panel的ID"); TextBox tb=(TextBox)p.FindControl("TextBox的ID"); string str=tb.Text;//此处就可以获取到 Panel 中的TextBox的内容}或者for(int i=0;i<Repeater1.Item.Count;i++){ Panel p= TextBox tb=Repeater1.Item[i].FindControl("Panel的ID").FindControl("TextBox的ID") as TextBox; string str=tb.Text;//此处就可以获取到 Panel 中的TextBox的内容} foreach( RepeaterItem item in this.Repeater1.Items ) {Panel p=item.FindControl("Panel1") as Panel; TextBox txt=p.FindControl("TextBox1") as TextBox; if(txt!=null){}} 我昏倒!!!!要清晰地意识到,如果这个时候不知道直接 Repeater1.Item[i].FindControl("TextBox的ID") 那么可能根本没有搞懂 FindControl 的机制。没有学到 FindControl 的机制,那么你可能既不知道知道什么时候必须使用中间层次的对象进行搜索,也不知道什么时候通过中间层次的对象进行搜索的多余的。 我在帖子 http://topic.csdn.net/u/20090412/22/63da66ba-aeb9-4254-a458-bcebf4df24a3.html 中有类似原理的回复(虽然问题并不完全相同)。 在看到楼主的问题“如何遍历Repeater 中 Panel 中的TextBox”之后,我的第一反应是打开 reflector 看看 Panel 到底有没有 INamingContainer 接口(因为我已经有近4年不做asp.net开发了,大多数东西都不确定了),看到它没有,我用1分钟做了一个程序实验,确定实际就是那样。 access 数据源转 sql 语句 想找外文翻译的资料,新闻发布系统 那为推荐个.net的视频教程,谢了 请"Jinglecat(晓风残月)"进来看一下, 一个高手才能做出的题!!!高手进!!1 RegularExpressionValidator怎么验证IP输入是不是正确? 问三个问题 怎么判断一个string s 是不是在“a,b,c,dd”中呢?简单的问题 如何在Server端指定打开一个新的窗口?如何使页面支持右键操作 FSO问题求救!!! Web.Config配置权限 上传ASPX网站后,提示“未能加载类型”
{
Panel p=(Panel)Repeater1.Item[i].FindControl("Panel的ID");
TextBox tb=(TextBox)p.FindControl("TextBox的ID"); string str=tb.Text;//此处就可以获取到 Panel 中的TextBox的内容
}或者
for(int i=0;i<Repeater1.Item.Count;i++)
{
Panel p=
TextBox tb=Repeater1.Item[i].FindControl("Panel的ID").FindControl("TextBox的ID") as TextBox; string str=tb.Text;//此处就可以获取到 Panel 中的TextBox的内容
}
{
Panel p=item.FindControl("Panel1") as Panel;
TextBox txt=p.FindControl("TextBox1") as TextBox;
if(txt!=null){}
}
要清晰地意识到,如果这个时候不知道直接 Repeater1.Item[i].FindControl("TextBox的ID") 那么可能根本没有搞懂 FindControl 的机制。没有学到 FindControl 的机制,那么你可能既不知道知道什么时候必须使用中间层次的对象进行搜索,也不知道什么时候通过中间层次的对象进行搜索的多余的。