I'm creating an MVC app in C# that accesses data in a sql database.
I have a table that gives a parent child relationship.
ID Name ParentID
1 A NULL
2 B 1
3 C 2
4 D 1
5 E 4
6 F NULL
The user is able to add more items to the table in other places in my app. I need to create a cascading dropdown starting at the root value(s) and populating further dropdowns with the next level of children. In addition next to each dropdown, I need to generate a button so that no matter how far into the dropdown tree the user goes, they can click on a button by any of the dropdowns and see information based on the selection of that particular dropdown.
Most of this is fairly simple to implement. My difficulty is how to dynamically generate an unknown number of dropdowns. I can create several and keep them hidden until needed, but there could always be more than I prepared for.
Rather than creating several dropdowns in my view and then hiding them, how do I dynamically create new dropdowns as needed?