Solved

View State Causing DataList to disappear

Posted on 2009-04-10
3
419 Views
Last Modified: 2012-05-06
We have a ArrayList that we bind to a DataList, then we create a viewstate that contains the ArrayList.  The final line in the code,

ViewState["ParamArray"] = alParams;

is causing the DataList to disappear when we debug. If I comment out the above line, the DataList appears. Any help is appreciated.

PS - I am kind of new to ASP.NET, so let me apologize if my phrasing or anything is incorrect.
//dlParams is a DataList
 

               ArrayList alParams= new ArrayList();

                

                foreach (string s in _xmlParams)

                {

                    ReportParameters reportParameters = new ReportParameters();

                    

                    etc, etc, etc, etc
 

                    reportParameters.ID = newID;

                    reportParameters.Caption = newTitle;

                    reportParameters.DefaultValue = defval;
 

                    alParams.Add(reportParameters);

                    dlParams.DataSource = alParams;

                    dlParams.DataBind();
 

                    ViewState["ParamArray"] = alParams;
 

                }

Open in new window

0
Comment
Question by:gregalhaig1
  • 2
3 Comments
 
LVL 15

Assisted Solution

by:spprivate
spprivate earned 100 total points
ID: 24117904
Move the view state commad out of the loop.
Also are you loading this Datalist in the pageload.If so make sure you put a  Postback check in the code
0
 

Author Comment

by:gregalhaig1
ID: 24118248
I am loading the DataList on a button_Click event. I did move it outside the loop, but so far same result as before.
0
 

Accepted Solution

by:
gregalhaig1 earned 0 total points
ID: 24119028
I used a session instead and that worked...not the exact way I wanted to do this, but it will work for now. Thanks for help!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
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: …

707 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

15 Experts available now in Live!

Get 1:1 Help Now