Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Select one dropdown value bind the values to combo box and select another dropdown value bind the values to same combo box but previous values are no changes ....?
Posted
Comments
thatraja 6-Nov-13 4:22am    
Confusing little bit. Rephrase you question. Explain the issue clearly.
member 8888995 6-Nov-13 5:02am    
Create a list as source for ComboBox.
Add Values in list on selection from dropdown.
set it as a source for ComboBox.
Again select from dropdown and add values to list
set it as a source for ComboBox.
Not clear. Explain again.

try this:

aspx page:


XML
<form id="form1" runat="server">
<div>
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
        onselectedindexchanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem>Akil</asp:ListItem>
        <asp:ListItem>Arun</asp:ListItem>
        <asp:ListItem>Balu</asp:ListItem>
        <asp:ListItem></asp:ListItem>
    </asp:DropDownList>
    <br />
    <br />
    <br />
    <asp:ComboBox ID="ComboBox1" runat="server" >

    </asp:ComboBox>
</div>
</form>



aspx.cs:


C#
int i = 0;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        ComboBox1.Items.Insert(i,DropDownList1.SelectedItem.Text);
        i++;
    }
 
Share this answer
 
Before binding values just write the following

C#
DropDownList1.Clear();


and then again bind the values. It will work.
 
Share this answer
 

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