Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all
I have problem related to combo box in C#.
What i want is...
i have to combo boxex. One contain group of products and there is another combo box where i want the sub products which will come based on the selection from combo box 1.
How can i do that.
Please send the code. I am a developer and need it urgently.
Thanking You
Updated 25-Nov-11 8:37am

On selected index changed/Value changed event of first combobox you will the id/value of the combobox,Based on the selected value you can load what ever the values you want to fill in the next combobox.
Share this answer
RaviRanjanKr 25-Nov-11 14:34pm    
A suggestion :- Please avoid using short text like u instead of using You.
protected void cmb1_OnSelectedIndexChanged(object sender,EventArgs e)
    long value = Convert.Int64(cmb1.SelectedValue);
void FillCombo2(long Combo1Value)
// fill dataset based on combo1Valuee and assign it to cmb2
    cmb2.dataSource = dt1;
    cmb2.DisplayMember ="Name";
    cmb2.ValueMember ="Id";

Mark as solution if its solved your problem
Share this answer
BillWoodruff 25-Nov-11 13:18pm    
This answer would be much more valuable if you showed how the passed in long, the value of 'Combo1Value in 'FillCombo2, was used to construct the dataset that I assume the name 'dt1 refers to.
Handle the SelectedIndexChanged[^] event for the first ComboBox, then update the second combo box based on the SelectedItem[^] value for the first ComboBox.
You can navigate given link for more reference
Update a combo box automatically when first combo box gets some value[^]
Share this answer
KAP75 26-Nov-11 5:08am    
Hi sagar15modi
I tried with the code u gave me. It gives error "Complex DataBinding accepts as a data source either an IList or an IListSource." What is this error i didnt understood this. Actually i forgot to inform in my question that i am using VS2008. Another thing is there is no function like DataBind(). so What to do.
Thanking You in advance.

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