locked
Dropdownlist inside checkboxlist RRS feed

  • Question

  • User953390479 posted

    Hi, I have a checkboxlist control which is bound to a database.

    If one of the checkboxes in checkbox1 is selected I want to be able to display a static checkboxlist with the same number of items as the 1st checkboxlist.

    If checkbox1 is selected I want the item in checkboxlist2 to be enabled but not visible if it is not selected.

    Also, can I display a dropdownlist in checkboxlist2 instead of checkboxes?

    This is what I have so far:

    <asp:CheckBoxList ID="CheckBoxList1" runat="server"

    DataSourceID="SqlDataSource6" AutoPostBack="true" DataTextField="ChannelName"

    DataValueField="ChannelID">

    </asp:CheckBoxList>

    <asp:CheckBoxList ID="CheckBoxList2" Visible="false" runat="server" AutoPostBack="True" AppendDataBoundItems="true">

    </asp:CheckBoxList>.

    Protected Sub CheckBoxList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBoxList1.SelectedIndexChanged

    Dim i As Integer

    CheckBoxList2.Items.Clear()

    For i = 0 To CheckBoxList1.Items.Count - 1

    CheckBoxList2.Items.Add(New ListItem("Chart Type"))

    CheckBoxList2.Visible = True

    CheckBoxList2.Items(i).Enabled = True

    If CheckBoxList1.Items(i).Selected Then

    Else

    CheckBoxList2.Items(i).Enabled = False

    End If

    Next

    End Sub

     

    Thanks

    Thursday, April 23, 2009 8:22 PM

Answers

  • User953390479 posted

    Thanks, Im using the gridview now instead

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 29, 2009 7:30 PM

All replies

  • User-1293249277 posted

    Also, can I display a dropdownlist in checkboxlist2 instead of checkboxes?

     

     

    Ya but for that u have to use Repeater control which shows the number of Dropwdowns lists.

    Friday, April 24, 2009 2:15 AM
  • User-1635004338 posted

    Hi rupertryan@hotmail.com,

    What do you mean "display a dropdownlist in checkboxlist2 instead of checkboxes"? I think it is impossible. They are totally different controls.

    Thanks,

    Wednesday, April 29, 2009 4:33 AM
  • User953390479 posted

    Thanks, Im using the gridview now instead

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 29, 2009 7:30 PM