Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Dynamic User Controls in a RepeaterDynamic User Controls in a Repeater
Previous
 
Next
New Post
10/24/2007 7:13 AM
 

I have a repeater on a View control, which iterates through a list of questions in a survey.  Each row in the question table can store a different question type, such as likert scale, single choice, multiple choice, free text etc.  The repeater's Item_bound event is used to create the quesion control pertaining to the question type, using the loadcontrol method. 

All my questions and associated controls display perfectly, but when I click the Save button, the results cannot be found.  I have attempted iterating through the repeater controls, but cannot see the underlying question control.  I've also tried many other remedies.

I would really appreciate any ideas on how I can grab the values from the dynamic user controls in the repeater.

Steve

 
New Post
10/24/2007 7:19 PM
 

Hi Steve,

I use dynamic controls in a repearer (and grid) that are generated according to a template for my UserProfile list control (e.g. Poker Players on PokerDIY). This bit of functionality drove me mad and I spent a good few weeks on it. It is is still not perfect, but it is working well. You need to recreate your controls after postback, as dynamically create controls are made too late in the event cycle to be recreated automatically after postback, hence they cannot be seen.

Having said that, I still spent ages tweaking it, but you can start by trying that if you have not done so...

 


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
10/24/2007 10:16 PM
 

Thanks for the prompt reply Rodney.  Pardon my ignorance - which event should I use to load the controls? 

Steve

 
New Post
10/25/2007 12:36 AM
 

I do mine in the Page Load event - I tried moving them about to get the best result - some things still do not work as I expect (you just need to fiddle with it a bit until everything is working)


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
11/21/2007 10:53 PM
 

As a matter of interest, after a great amount of searching I resolved this issue.  This post is to help any other poor sucker who encounters the same frustration as I did.

Creating the Controls

1. The User Controls must be created/initialised in your view module using the Page_Init event.  If you create/initialise the controls in the page_load event, it is too late in the page cycle for ASP.Net to recognise the identity of the controls in viewstate.  So when you search for the controls to save the corresponding data, Dot Net cannot see them.  I created all of the User Controls inside a placeholder on the View Control page, as I said in the Page_Init event.

2.  Make sure that the User Controls that you have created to appear on your View Module, have had their individual server controls initialised also in the Page_Init event, for the same reason as 1. above.  So when your User Controls are initialised, their server controls are recognised in viewstate.  Indeed if you were nesting user controls inside other user controls, I would think that all of them would need to be created in the page_init event.

3.  Every control must have a unique ID, so that later you are able to locate them for saving data.

Saving the Data in the Controls

When you are ready to save the data entry into the nested user controls, use the Page_load event of your main view control to trap the values in each of the user controls. 

You will need to find the controls using the FindControl method, and step through the controls that are referenced as nested controls of the placeholder.

Place the "SaveData" method in the Page_Load event, inside "If Page.IsPostback". 

Debugging

If you step through the debugger, you will notice each of the controls being created twice, whenever an event occurs.  However asp.net maintains persistance of the data values in the controls (using viewstate), and even though this process seems counter-intuitive, it works.

If anyone has any questions or comments, I'm happy to contribute more to this in the hope that I can assist someone else.

Steve

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Dynamic User Controls in a RepeaterDynamic User Controls in a Repeater


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out