| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 427 人关注过本帖
标题:控件赋值
只看楼主 加入收藏
cxwl3sxl
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:495
专家分:129
注 册:2005-11-12
结帖率:100%
收藏
 问题点数:0 回复次数:3 
控件赋值

在asp.net中,有没有办法对一组名字有规则的控件赋值啊?
如有控件
protected System.Web.UI.WebControls.RadioButton RadioButton1;
protected System.Web.UI.WebControls.RadioButton RadioButton2;
protected System.Web.UI.WebControls.RadioButton RadioButton3;
protected System.Web.UI.WebControls.RadioButton RadioButton4;
protected System.Web.UI.WebControls.RadioButton RadioButton5;
protected System.Web.UI.WebControls.RadioButton RadioButton6;
protected System.Web.UI.WebControls.RadioButton RadioButton7;
protected System.Web.UI.WebControls.RadioButton RadioButton8;
protected System.Web.UI.WebControls.RadioButton Radiobutton9;
protected System.Web.UI.WebControls.RadioButton Radiobutton10;
还有一个字符串数组(string[] bt=new string[10];),共有10个值,有没有办法用循环来对实现下面的功能啊?
RadioButton1.text=bt[0];
RadioButton2.text=bt[1];
.
.
.
RadioButton10.text=bt[9];


搜索更多相关主题的帖子: 赋值 控件 
2006-10-02 20:30
cxwl3sxl
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:495
专家分:129
注 册:2005-11-12
收藏
得分:0 
怎么没有人啊?

努力,哈哈,总有一天会变成高手~~~~~~因为我相信:没有办不到,只有想不到!http://t..cn/fpress
2006-10-02 20:47
mylover624
Rank: 1
来 自:乖乖的心中
等 级:新手上路
帖 子:868
专家分:0
注 册:2006-7-6
收藏
得分:0 
string[] bt=new string[10];

for(inr i = 1 ; 1 < =10 ; i++)
{
RadioButton MyRadioButton = new RadioButton();
MyRadioButton.Text = bt[i].ToString();
MyRadioButton.ID = "RadioButton" + i.ToString();
PlaceHolder1.Controls.Add(MyRadioButton);
}

一个天才顶不上十个笨蛋!
书山有路勤为径,学海无涯友相伴。
我的E-mail:mylover624@.cn
2006-10-03 15:17
cxwl3sxl
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:495
专家分:129
注 册:2005-11-12
收藏
得分:0 

谢谢,已经解决了!


努力,哈哈,总有一天会变成高手~~~~~~因为我相信:没有办不到,只有想不到!http://t..cn/fpress
2006-10-04 19:03
快速回复:控件赋值
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011795 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved