Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
hello all,

Please provide me code in asp.net vb code for linking two dropdowns

Regards
Ananth
Posted

Please Follow Following Steps.

1. Create Function to get Data For First Dropdown.
2. set datatext and datavalue property of dropdown to database table columns.
3. Assign Datasource and call databind property of first dropdown.
4. on selected index change event, get selected value/text from first dropdown and get data for second dropdown using where condition.
5. follow step 2 and 3 for second dropdown.
 
Share this answer
 
Hi...

Try this...


protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = objDA.GetList();
DropDownList1.DataSource = dt;
DropDownList1.DataBind();

}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex > 0)
{

DataTable dt = new DataTable();
dt = objDA.GetList(DropDownList1.SelectedValue);
DropDownList1.DataSource = dt;
DropDownList1.DataBind();
}
}
 
Share this answer
 
Just Google or use CP Search for "Cascading dropdown"

Try, use/implement it. If you face issues while implementing it then do share across your effort with issues.
 
Share this answer
 
please provide me code for this
 
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