I have a table with 3 columns
EmployeeId EmployeeName ReportingTo 1 A 2 B 1 3 C 1 4 D 1 5 E 2 6 F 3 7 I 3 8 J 4 9 K 8
Employee Ids are unique. ReportingTo is id of person to whom employee is reporting. ReportingTo is null means A is Boss.
In Asp.net, I want to create a page with one dropdownlist by default. In that dropdownlist EmployeeId whose reportingto is null will be loaded. when I select that dropdown with EmployeeId 1 then next dropdownlist will get created & fill with employees who are reporting to EmployeeId 1.
I have created this whole page, but for that i am generating dropdownlist manually in aspx page.
Anyone can guide me how to create this scenario with dynamic dropdownlist, so I can generate any number of dropdowns & fill it dynamically.
You can add a placeholder control on your web page and then create the new dropdown and add it to the placeholder like so:
private void AddDropDown(){
var dl = new DropDownList();
dl.ID="empDDL";
dl.DataSource = list;
dl.DataBind();
myPlaceholer.Controls.Add(dl);
}
Hope this helps.
You use ASP.Net cascade dropdownlist. This example
http://www.aspsnippets.com/Articles/Creating-Cascading-DropDownLists-in-ASP.Net.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.