怎样动态产生控件Radio 现在我要根据数据库表中的某一列来产生Radio,执行查找语句后得到想要的数据。有一个就生成一个Radio。还有怎样把生成的Radio加入前台的ASPX页中相应的位置?哪位大侠帮帮忙? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 前台<asp:Panel ID="Panel1" runat="server"> </asp:Panel>后台 (.cs文件)RadioButton rb = new RadioButton(); rb.Text = "值"; rb.ID = "id"; Panel1.Controls.Add(rb);这应该是你想要的效果。但是你应该用RadioButtonList才对呀<asp:RadioButtonList ID="RadioButtonList1" runat="server"> </asp:RadioButtonList>for (int i=0; i<10; i++) { RadioButtonList1.Items.Add(i.ToString()); RadioButtonList1.Items[i].Value = i.ToString(); } 是的,贴发完才发现要用RadioButtonList,呵呵。非常感谢。 js不起作用 ConfigurationSourceFactory.Create的问题 谁知道哪里有仿PPLIVE或第一放映室网站的源码 ASP.NET skin和css的区别 讨论帖 实体类和结构体的区别 C#和JavaScript如何配合... 关于学习asp.net的视频推荐 GridView中的邦定? 在页面中使用datagrid,它接受的返回类型为DataSet和ds.Table[0],同样都能暴露数据库的表结构吗? 一个小问题求帮助,先谢谢了! 简单的XML问题!!!(不帮忙就会死人了@.@) ASPX页面下载问题
</asp:Panel>后台 (.cs文件)RadioButton rb = new RadioButton();
rb.Text = "值";
rb.ID = "id";
Panel1.Controls.Add(rb);这应该是你想要的效果。
但是你应该用
RadioButtonList才对呀<asp:RadioButtonList ID="RadioButtonList1" runat="server">
</asp:RadioButtonList>
for (int i=0; i<10; i++)
{
RadioButtonList1.Items.Add(i.ToString());
RadioButtonList1.Items[i].Value = i.ToString();
}