Groups | Blog | Home
all groups > dotnet general > august 2006 >

dotnet general : Recommended way to add child controls in CreateChildControls


paul.hester NO[at]SPAM gmail.com
8/2/2006 10:32:50 PM
Hi all,

What is the recommended way to add child controls *around* existing
child controls in the CreateChildControls method (e.g. table, row and
cell controls for layout purposes)?

Is the best way to keep a reference to the existing child controls,
clear the Controls collection and then re-add everything along with the
layout controls, or insert the layout controls around the existing
controls in the existing Controls collection?

Thanks,

Paul
paul.hester NO[at]SPAM gmail.com
8/3/2006 1:23:08 PM
If I try to modify the Controls collection, I get a "The Controls
collection cannot be modified because the control contains code blocks"
error because my controls contain literal content (i.e. <%=
SomeValue%>). If I change the literal content to a <%# %> tag it
doesn't get picked up and is rendered empty.

Is there any way to insert layout controls around the existing controls
and preserve the literal content?

Any help would be appreciated. I'm stuck on this one.

Thanks,

Paul

[quoted text, click to view]
AddThis Social Bookmark Button