Nested user controls
-
Hi, I have a user control. It should display a list of employees in a department, but in a nested way. It is currently defined like this: - It contains a single div. - Inside this div there are three controls: - A HyperLink control (showing the name of the department) - A GridView control (listing all employees within this department) - A Repeater control (which should display all sub-departments). The repeater should actually contain a copy of the user control itself!, since it is really displaying the exact same information, only for subdepartments - and there could be an (theoretically) infinite amount of nested subdepartments. Now, obviously a user control cannot directly contain a control which is an instance of itself. However, I've managed to bypass that problem by letting the repeater contain a single PlaceHolder, and then use LoadControl to load any number of the UC. This works correctly and all the data is displayed - but in the same gridview: the gridview defined in the first UC which is loaded with LoadControl. All the others are empty. It appears that when I call e.Item.FindControl during the ItemDataBound event for the repeater, it always seems to give me the same control. Has anyone had any similar problem - or what is more important - a solution? Regards, Daníel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
-
Hi, I have a user control. It should display a list of employees in a department, but in a nested way. It is currently defined like this: - It contains a single div. - Inside this div there are three controls: - A HyperLink control (showing the name of the department) - A GridView control (listing all employees within this department) - A Repeater control (which should display all sub-departments). The repeater should actually contain a copy of the user control itself!, since it is really displaying the exact same information, only for subdepartments - and there could be an (theoretically) infinite amount of nested subdepartments. Now, obviously a user control cannot directly contain a control which is an instance of itself. However, I've managed to bypass that problem by letting the repeater contain a single PlaceHolder, and then use LoadControl to load any number of the UC. This works correctly and all the data is displayed - but in the same gridview: the gridview defined in the first UC which is loaded with LoadControl. All the others are empty. It appears that when I call e.Item.FindControl during the ItemDataBound event for the repeater, it always seems to give me the same control. Has anyone had any similar problem - or what is more important - a solution? Regards, Daníel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!