有关添加动态控件的问题?
为什么RadioButtonList控件放在外面添加动态选项就可以执行,而放在DataList控件或者是Table控件里面就不能执行?
相应代码前台代码:
<asp:datalist id="DataList1" runat="server" Width="100%" Font-Size="Smaller">
<ItemTemplate>
<FONT face="宋体">
<P> </P>
<P> <asp:RadioButtonList id="RadioButtonList1" runat="server" Font-Size="X-Small"></asp:RadioButtonList></P>
</FONT>
</ItemTemplate>
</asp:datalist>
<asp:RadioButtonList id="RadioButtonList2" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 296px" runat="server"></asp:RadioButtonList>
后台代码:
ArrayList MyArray = new ArrayList();
MyArray.Add("1.aaa");
MyArray.Add("2.bbb");
MyArray.Add("3.ccc");
MyArray.Add("4.ddd");
MyArray.Add("5.eee");
MyArray.Add("6.fff");
MyArray.Add("7.ggg");
MyArray.Add("8.hhh");
MyArray.Add("9.iii");
RadioButtonList2.RepeatDirection = RepeatDirection.Horizontal;
RadioButtonList2.DataSource = MyArray;
RadioButtonList2.DataBind();
请问上面这种情况该怎么解决?谢谢!