当前位置: 代码迷 >> ASP.NET >> 取Panel里的控件有关问题
  详细解决方案

取Panel里的控件有关问题

热度:9974   发布时间:2013-02-26 00:00:00.0
取Panel里的控件问题。
int   num=1;
while(reader.Read())
{
RadioButtonList   rbtnList=new   RadioButtonList();
rbtnList.ID= "rbtnList "+num.ToString();
rbtnList.Items.Add( "A.   "+Server.HtmlEncode(reader[ "testAns1 "].ToString()));
rbtnList.Items.Add( "B.   "+Server.HtmlEncode(reader[ "testAns2 "].ToString()));
rbtnList.Items.Add( "C.   "+Server.HtmlEncode(reader[ "testAns3 "].ToString()));
rbtnList.Items.Add( "D.   "+Server.HtmlEncode(reader[ "testAns4 "].ToString()));
num++;
}
                                   

这样在Panel里建立的控件,
RadioButtonList   list;
  list   =   (RadioButtonList)Panel1.FindControl( "rbtnList "   +   i.ToString());

list为什么是Null

------解决方案--------------------------------------------------------
RadioButtonList list;
list = (RadioButtonList)FindControl( "rbtnList " + i.ToString());

------解决方案--------------------------------------------------------
这个问题,我在半年前也遇到过,后来改用FormView了.行.