手动做了个简单列子,希望有所帮助
前台
<div>
<asp:CheckBoxList AutoPostBack="true" runat="server" onselectedindexchanged="CheckBoxList1_SelectedIndexChanged">
<asp:ListItem Value="1">选中</asp:ListItem>
<asp:ListItem Value="2">未选中</asp:ListItem>
</asp:CheckBoxList>
<asp:Panel runat="server">
</asp:Panel>
</div>
后台
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (CheckBoxList1.SelectedValue == "1")
{
CheckBoxList che2 = new CheckBoxList();
ListItem li = new ListItem("选中的时候", "1");
che2.Items.Add(li);
Panel1.Controls.Add(che2);
}
if (CheckBoxList1.SelectedValue == "2")
{
CheckBoxList che2 = new CheckBoxList();
ListItem li = new ListItem("未选中的时候", "2");
che2.Items.Add(li);
Panel1.Controls.Add(che2);
}
}