首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

FindControl的有关问题

2012-04-10 
FindControl的问题根据历史记录的数量,循环创建Table依次显示历史记录C# code//在table的单元格td_1_1中自

FindControl的问题
根据历史记录的数量,循环创建Table依次显示历史记录

C# code
//在table的单元格td_1_1中自动创建一个CheckBox:cb1_1_1Anthem.CheckBox cb1_1_1 = new Anthem.CheckBox();            cb1_1_1.ID = string.Format("cbChoose{0}", dt.Rows[i]["Number"].ToString());            cb1_1_1.AutoUpdateAfterCallBack = true;            cb1_1_1.Checked = false;            td1_1.Controls.Add(cb1_1_1);[code][code=C#]//在某个按钮点击事件中Anthem.CheckBox cbChoose = (Anthem.CheckBox)this.FindControl(string.Format("ctl00_ContentPlaceHolder1_cbChoose{0}", dt.Rows[i]["Number"].ToString()));


//ctl00_ContentPlaceHolder1_cbChoose1是界面显示出来后查看源码里面看到的id
//但是这时候取到cbChoose为null,为什么?

[解决办法]
如果checkbox外边还有服务器控件,this.FindControl,这样就不行了
你可以看下父控件的controls

热点排行