473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Repeater, Panel, dynamic user control - can't retrieve dynamic controls in code behind

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:Panel id="attPanel" runat="server"></asp:Panel>
<%# 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
Nov 16 '05 #1
2 5289
Are you recreating all the dynamic controls on postback? Because they won't
recreate themselves like the controls you hard coded in your .aspx - you
have to readd them manually.

"theComputer7" <do******@hardingmarketing.com> wrote in message
news:8c**************************@posting.google.c om...
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:Panel id="attPanel" runat="server"></asp:Panel>
<%# 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

Nov 16 '05 #2


If I recreate them I can repopulate them. But all I really want to do
is get the values from the first set and redirect to another page.
There is no error handling or posts back to the page for any reason.
How do I capture the values from the elements the first submit?

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Fraggle | last post by:
I have a repeater with controls added at run time. the <template> also contains a <asp:textbox that is made visible on some repeater elements. when I come to read the text info out it has...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
5
by: UnknownServices | last post by:
I've added a LinkButton to a repeater control and I set the link button as follows: <asp:LinkButton ID="DLLinkButton" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "DownloadID")%>'...
7
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the...
4
by: Dennis E. Jones, Jr. | last post by:
I'm creating a dynamic control for each row in a REPEATER based on database values. ItemDataBound creates the control for the initial load (not postback), but I cannot get the control recreated...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
7
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
1
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business...
14
by: Adam Sandler | last post by:
I have a class with a method which returns a panel. The panel was not created with the visual editor, I coded it by hand -- because some of the content on the panel can be dynamic and thus I chose...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.