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

怎样用C#代码动态生成CheckBoxList解决办法

2011-12-25 
怎样用C#代码动态生成CheckBoxList生成的CheckBoxList如下所示,怎么整啊?asp:CheckBoxListid CheckBoxL

怎样用C#代码动态生成CheckBoxList
生成的CheckBoxList如下所示,怎么整啊?

<asp:CheckBoxList   id= "CheckBoxList1 "   runat= "server "   RepeatDirection= "Horizontal "   RepeatColumns= "3 ">
<asp:ListItem   Value= "a "> a </asp:ListItem>
<asp:ListItem   Value= "b "> b </asp:ListItem>
<asp:ListItem   Value= "c "   Selected= "True "> c </asp:ListItem>
</asp:CheckBoxList>

[解决办法]
CheckBoxList cbl = new CheckBoxList(); cbl.Items.Add(new ListItem( "a ", "a ")); cbl.Items.Add(new ListItem( "b ", "c ")); cbl.Items.Add(new ListItem( "c ", "c ")); cbl.SelectedIndex = 2; this.panel1.Controls.Add(cbl);
[解决办法]
什么是动态生成网页?你说的“页面上方一个控件”,而你的页面不能放东东,这其实就是“绕”的说法。你说的页面是asp.net的page吗?如果是,连page都也不过是个控件,怎么就找不到容器位置(?)。如果你不打算动态产生asp.net页面,就不是asp.net问题了。

热点排行