Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to use two comboboxes.
Both combobox data fill from database.

I want second combobox to populate based on selected value from the first combobox.



Please give proper code.
Posted
Updated 7-Sep-10 22:42pm
v2
Comments
Dalek Dave 8-Sep-10 4:42am    
Edited for Grammar and Syntax.
Toli Cuturicu 8-Sep-10 7:14am    
Reason for my vote of 1
Don't ask for code! Show us what you've done and is not working as expected!

On selectedItemChanged event of the first you load the values of the second combo, using the selectedValue of the first as parameter to your database call.

Ex:


C#
protected void ddlCity_SelectedIndexChanged(object sender, System.EventArgs e)
{
    
        ddlStreet.DataSource = Dal.GetStreetsByCity(ddlCity.SelectedItem.Text);
        ddlStreet.DataTextField = "streetName";
        ddlStreet.DataValueField = "idStreet";
        ddlStreet.DataBind();
        
    }
}
 
Share this answer
 
Comments
Dalek Dave 8-Sep-10 4:43am    
Good Call.
Krauze wrote:
pls give proper code...
Please don't ask for ready-to-run code.

The ComboBox class has all you need and MSDN provides full documentation (see, for instance, the example in ComboBox Class[^] overview).

:)
 
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