Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

View State Causing DataList to disappear

Posted on 2009-04-10
3
Medium Priority
?
478 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Assisted Solution

by:spprivate
spprivate earned 400 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 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