Click here to Skip to main content
15,887,272 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There is a drop-down-list on the page; What i want here is to display different items for different situations.

such as: for you check "check-box A", item A, B, C can be displayed; and checking "check-box B", item C, D, E should be displayed...

is there any way to make it?

BTW, I use C#, and VB....

thanks,
Jessie
Posted
Updated 27-May-12 23:28pm
v2

Create class item that contain:

C#
Public Class item
{
 string Value{get; set;}
 string ID{get; set;}
 string Flag {get; set;}
}


and give for first group all of them Flag = "a" second class Flag = "b" and so on and when you load you data from data base and when you need to bind the data filter them according to its flag

note: also add column in database called flag to save each item belong to which criteria... best regards
 
Share this answer
 
try like this
VB
'In Source
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True">
        <asp:ListItem>A</asp:ListItem>
        <asp:ListItem>B</asp:ListItem>
        <asp:ListItem>C</asp:ListItem>
    </asp:CheckBoxList>
'In Code:
Protected Sub CheckBoxList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBoxList1.SelectedIndexChanged
        If (CheckBoxList1.SelectedItem.Text = "A") Then
            DropDownList1.Items.Add("A")
            DropDownList1.Items.Add("B")
            DropDownList1.Items.Add("C")
        ElseIf CheckBoxList1.SelectedItem.Text = "B" Then
            DropDownList1.Items.Add("D")
            DropDownList1.Items.Add("E")
            DropDownList1.Items.Add("F")
        ElseIf CheckBoxList1.SelectedItem.Text = "C" Then
            DropDownList1.Items.Add("G")
            DropDownList1.Items.Add("H")
            DropDownList1.Items.Add("I")

        End If

    End Sub
 
Share this answer
 
v2
Comments
DevSRKin 28-May-12 6:01am    
Thanks for the quick response. I know your point. Then there will be lots of items to be added ... and there will be a problem, that is, if there is a same item for 2, or more situations... little bit complicated to make them clearly added, such as check A, then B, then A... for the check box, you know..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900