Solved

ASP composite control with Datalist / Viewstate

Posted on 2004-04-20
5
422 Views
Last Modified: 2012-05-04

  I have a composite control that is dynamically loaded into a placeholder at runtime.

  All values on the control display properly including the datalist.  The datalist is not bound,  one list item is manually added.  

  On a postback that does nothing but refresh the page all controls display with the original values except the datalist.  I have a button to reload the datalist, when this is clicked, then all subsequent postbacks (refreshs of the page) retain the values in the datalist.

  The datalist does seem to retain viewstate on subsequent postbacks?   Instantiating the control from Init solves the problem..

  However, I am generating the controls off events,  I'm attempting not to use querystrings, but it may seem that is necessary.  

  I would except an example of how to use httpContext or other routes to capture postback information to generate the required control in the Init method.

  Thanks!!


0
Comment
Question by:dlarlick
  • 3
  • 2
5 Comments
 
LVL 2

Author Comment

by:dlarlick
ID: 10871671

Sorry it's a listbox not a datalist.  I see others have the same problem.

Need to persist listbox on initial load of control.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 10875625
do you say that when you do postback all of the controls ( dynamically added ) are showing correct except the listbox ?
if this is correct can you post the code that you recreate the controls ( or the code that you show the controls )

B..M
0
 
LVL 2

Author Comment

by:dlarlick
ID: 10877600

  The control is a composite control dynamically added to a placeholder based on a menu option.  All the controls within the composite control are added at design time.

  All the controls within the composite control show correct with values on the initial display.  A postback on the form will redisplay all controls correct with values EXCEPT the listbox.  The listbox control is there but all values are cleared.

  I took a look at the problem last night and loaded the project on my laptop.  For whatever reason the app on my laptop behaves correctly.

  I am looking into the possible differences...

  I will post a followup...  Thank you for your response.
0
 
LVL 2

Author Comment

by:dlarlick
ID: 10888153

  I believe the complication was due to attempting to initialize a value in the page_load of the control.

  Something with the viewstate seems to get confused when attempting to perform some simple processing in the page_load of the control.  I have removed all page_load processing from the control and no longer have the complication.  

  please close thread.
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 500 total points
ID: 10888357
sorry, but i'm not a Page Editor in this TA and can not close the question
you have to post a question in Community Support to close this question

B..M
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now