Parent Control containing child control which is of same type as parent control
I need to create a asp.net form which needs to show a list of folders开发者_运维知识库 where each folder may further contain other folder and file. Like window folder view it can be nested to n-level. I can't use tree view control as some edting and formatting requirement can't be met. The datastructure i am using is not folder view but almost same as folderview.
I first tried to create a usercontrol, say FolderList,showing list of folders. It contains listview where each item of the listview shows the name of the folder and also contains an instace another UserControl, say folderDetail. folderDetail contains an instance of Usercontrol FolderList and a listview showing files in those folders. But it failed with the exception "Circular file references are not allowed".
Next i am thinking if i can add control dynamically and get Ajax working on it someway. But that gonna take some effort.
Please suggest me a proper solution so that such nested struture can be displayed?
You can add controls dynamically, also without ajax. In the databound event of the list view load and add the user control you need, dynamically with the LoadControl
function.
精彩评论