1 回答

TA貢獻1828條經(jīng)驗 獲得超4個贊
手動做了個簡單列子,希望有所幫助
前臺
??? <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);
??????? }
??? }
- 1 回答
- 0 關(guān)注
- 426 瀏覽
添加回答
舉報