Click here to Skip to main content
15,896,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to display the values in DropDown2 but it have to display based on the selection in Dropdown1.

Eg: DropDown1 contains 2 values(A,B) if i choose A then Dropdown2 have to display 1A 2A

if (DropDownList1.SelectedItem.Text.Equals("A"))
{
DropDownList2.Items.Add(new ListItem("1A", "0"));
DropDownList2.Items.Add(new ListItem("2A", "1"));

}
else if(DropDownList1.SelectedItem.Text.Equals("B"))
{
DropDownList2.Items.Add(new ListItem("1B", "0"));
DropDownList2.Items.Add(new ListItem("2B", "1"));
}

I have check the Autopushback= true for both the dropdown. Please help me out on this and thanks in advance!!!
Posted
Updated 23-Jul-14 18:59pm
v2

1 solution

CComboBox m_cComboSateName1,m_cComboSateName2;
CString CStemp;
m_cComboSateName1.GetWindowTextW(CStemp);

if (CStemp.compare("A")==0)
{
m_cComboSateName2.AddString("1A");
m_cComboSateName2.AddString("2A");
}
else if(CStemp.compare("B")==0))
{
m_cComboSateName2.AddString("1B");
m_cComboSateName2.AddString("2B");
}


//Something exactly like this,But please check the compare function or any other syntax mistake.Also check if u r using unicode or multi in case of string comparasion
 
Share this answer
 
v2

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