Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how do i populate a dropdownlist with another dropdownlist list using a selected value, i tried the following code but it populates the ddl with business logic.

protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
     {
            Service obj = new Service ();
            List <Service > slist = new List<Service> ();
            Int32 ser = Convert .ToInt32  (DropDownList2.SelectedValue);
            slist = obj.allServcieBYfk(ser);
            drpDwnService.DataSource = slist;
            
            drpDwnService.DataBind();
        }
Posted
Updated 4-Jul-11 2:28am
v2
Comments
[no name] 4-Jul-11 8:26am    
What exactly you want? Do you want to fill a dropdownlist on the selectedIndexchanged method of another dropdownlist??
[no name] 4-Jul-11 8:29am    
Format any code posted using the code block toolbar item

"but it populates the ddl with business logic"

slist = obj.allServcieBYfk(ser);
drpDwnService.DataSource = slist;


Yes, that is doing exactly what it is you are asking it to do.

What is it you expect to happen?
 
Share this answer
 
Comments
Monjurul Habib 4-Jul-11 15:50pm    
good call, my 5.
Mark is right, Not clear what's the matter? For further reading see these

Cascading DropDownList Populate dropdown based on selection of other dropdown in ASP.NET[^]
CascadingDropDown[^]
 
Share this answer
 
Comments
Monjurul Habib 4-Jul-11 15:48pm    
nice links, my 5.

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