Solved

View State Causing DataList to disappear

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is Thread.Sleep? 5 46
In WPF / C# binding a local database in code behind 1 24
Angular JS Route 3 54
Connection String 16 43
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

895 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