Solved

View State Causing DataList to disappear

Posted on 2009-04-10
3
452 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 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