T
theComputer7
I cut down the code to make this half way understandable... I have
read Data Grid girls caution about over use of dynamic controls. I
truly believe what I am doing requires dynamically inserted user
controls.
Worse I'm trying to add dynamic user controls from within a repeater
loop (looping through attributes)... I bind to a function in the code
behind and pass in the attribute.
<asp:repeater id="rAttributes" Runat="server">
<ItemTemplate>
<asp
anel id="attPanel" runat="server"></asp
anel>
<%# InsertAttributeControl(Container)%>
</ItemTemplate>
</asp:repeater>
In the code behind I determine what type of attribute I'm dealing with
(polymorphism) and create the appropriate control to render it. I
create the control and insert it into a panel as google groups has
suggested...
// Load the UserControl.
myLB theControl = (myLB)LoadControl("../Controls/myListBox.ascx");
if (theControl != null)
{
theControl.ID = "attControl";
theControl.DataSource = theEnumAtt.Enums;
theControl.DataTextField = "EnumName";
theControl.DataValueField = "EnumID";
theControl.DataBind();
// Add control to placeholder
attPanel.Controls.Add(theControl);
}
the user updates the form and submits to a wired event..... I spin
through the repeater and get the panel (attPanel), but when I check
the attPanel.HasControls() and it returns false. It seems the dynamic
controls have disappeared.
foreach (RepeaterItem ri in rAttributes.Items)
{
// get controls
Panel attPanel = ((Panel)ri.FindControl("attPanel"));
myLB theAttEnum = ((myLB)attPanel.FindControl("attControl"));
}
Any ideas?
Thanks,
Don
read Data Grid girls caution about over use of dynamic controls. I
truly believe what I am doing requires dynamically inserted user
controls.
Worse I'm trying to add dynamic user controls from within a repeater
loop (looping through attributes)... I bind to a function in the code
behind and pass in the attribute.
<asp:repeater id="rAttributes" Runat="server">
<ItemTemplate>
<asp
<%# InsertAttributeControl(Container)%>
</ItemTemplate>
</asp:repeater>
In the code behind I determine what type of attribute I'm dealing with
(polymorphism) and create the appropriate control to render it. I
create the control and insert it into a panel as google groups has
suggested...
// Load the UserControl.
myLB theControl = (myLB)LoadControl("../Controls/myListBox.ascx");
if (theControl != null)
{
theControl.ID = "attControl";
theControl.DataSource = theEnumAtt.Enums;
theControl.DataTextField = "EnumName";
theControl.DataValueField = "EnumID";
theControl.DataBind();
// Add control to placeholder
attPanel.Controls.Add(theControl);
}
the user updates the form and submits to a wired event..... I spin
through the repeater and get the panel (attPanel), but when I check
the attPanel.HasControls() and it returns false. It seems the dynamic
controls have disappeared.
foreach (RepeaterItem ri in rAttributes.Items)
{
// get controls
Panel attPanel = ((Panel)ri.FindControl("attPanel"));
myLB theAttEnum = ((myLB)attPanel.FindControl("attControl"));
}
Any ideas?
Thanks,
Don