C# – Display the items in DropDownList

c

In my project i have used four number of dropdownlists in a single form.

when im selecting an item from the 1st dropdownlist,the dropdownlist2 has to display the items that matches the selected item from dropdowmlist1.
Please clear my doubt.,

Best Answer

Use the SelectedIndexChanged-event on the first dropdownlist. Everytime the user selects a different item in the dropdownlist, this event is fired. In the method body you can now react to the change and filter the items of the second dropdownlist to match the selected item of the first dropdownlist. You can either do that manually in a loop or use LINQ (Enumerable.Select).