Link to home
Start Free TrialLog in
Avatar of gregalhaig1
gregalhaig1

asked on

View State Causing DataList to disappear

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

SOLUTION
Avatar of spprivate
spprivate
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gregalhaig1
gregalhaig1

ASKER

I am loading the DataList on a button_Click event. I did move it outside the loop, but so far same result as before.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial