请教一个问题,我遍历Form1的所有控件写了两种写法,
1 foreach (Control c in thiPg.FindControl("Form1").Controls)
{
if (c.GetType() == new TextBox().GetType())
{
TextBox txt = (TextBox)c;
if (showNow)
{
txt.Text = (prs[x].GetValue(myClass, null)).ToString(); //给txt赋值
x++;
}
else
{
txt.Visible = false;
} }通过2
int x = 0;
if (obj.GetType() == new TextBox().GetType())
{
x = 1; foreach (Control c in thiPg.FindControl("Form1").Controls)
{
if (yes)
{
if (c.GetType() == new Label().GetType())
{
TextBox txt = (TextBox)c;
txt.Visible = true;
txt.Text = txtString;
x++;
}
}
失败请问这个为什么失败,要如何去改尼。
1 foreach (Control c in thiPg.FindControl("Form1").Controls)
{
if (c.GetType() == new TextBox().GetType())
{
TextBox txt = (TextBox)c;
if (showNow)
{
txt.Text = (prs[x].GetValue(myClass, null)).ToString(); //给txt赋值
x++;
}
else
{
txt.Visible = false;
} }通过2
int x = 0;
if (obj.GetType() == new TextBox().GetType())
{
x = 1; foreach (Control c in thiPg.FindControl("Form1").Controls)
{
if (yes)
{
if (c.GetType() == new Label().GetType())
{
TextBox txt = (TextBox)c;
txt.Visible = true;
txt.Text = txtString;
x++;
}
}
失败请问这个为什么失败,要如何去改尼。
解决方案 »
- 数据库表的设计问题求解
- 【急切求助】请大家简要介绍下AJAX、XML、CSS、JavaScript主要功能和相互关系,谢谢。。。
- 数据被修改了 如何恢复到修改前
- (在线等)关于控制div标签显示隐藏的问题
- 请教高手,如何使用.net 连接SQL Sever里的数据仓库
- 自定義表頭和Datagrid綁定數據格式上下不可對齊
- 一个WEBFROM中的DataGrid的奇怪的问题!
- 为什么我用vs.net新建asp.net应用程序出错?无法创建web项目,object not found?
- 检测到无法访问的代码
- 论坛的文章如何保存,怎么找不到下载XSL的地方????
- 有多个提交控件时,怎么有选择的验证?
- 帮忙看看这条sql语句
第二种方法 我传了个控件,不是webCOnt啥啥,而是contr...我看到错误了。。我回头改一下。这个先留在这,这一段时间可能太累了,代码都看不下去了。