Solved

Viewstate changes not persisting while using updatepanel

Posted on 2009-07-09
9
1,901 Views
Last Modified: 2013-11-07
When I update Viewstate runtime and saving, it is not keeping the changes in viewstate   after I do partical postback using ajax update panel control
0
Comment
Question by:ravifine
  • 4
  • 3
9 Comments
 

Author Comment

by:ravifine
ID: 24817166
Hi,
it's urgent. Can any one suggest me.

Here is my scenario

I have public property which contains some object. I'm saving that object in viewstate. When I use update panel and doing partial postback, the changes which I made to  my public property are not persisting in viewstate.
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24817473
how you are saving those in vewstate.
You could also use a session to save your object. i know it work with update panel.
0
 

Author Comment

by:ravifine
ID: 24817607

//this is my property
private Dictionary<string, List<Event>> EventsDictionary
                  {
                        get
                        {
                              if (ViewState["EventsDictionary"] != null)
                              {
                                    return (Dictionary<string, List<Event>>)ViewState["EventsDictionary"];
                              }
                              else
                              {
                                    return null;
                              }
                        }
                        set
                        {
                              ViewState["EventsDictionary"] = value;
                        }
                  }

// this is my code which modifies  EventsDictionary object and keeping in viewstate

                              Dictionary<string, List<Event>> eventDictionary = EventsDictionary;
                              Dictionary<string, string[]> weekEvents = WeekEvents;
                              ScheduleManager.CopyDayEventsToAnotherDay(ref eventDictionary);// here I'm updating my EventDictionary object.
                              EventsDictionary = eventDictionary;
                              eventDictionary = null;

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:ravifine
ID: 24817614
Advance thanks for your help
0
 
LVL 18

Accepted Solution

by:
David Robitaille earned 250 total points
ID: 24817769
hummm... it work without the update panel?
If yes, make sure the update panel dont generate an error that block the update.
Also, i thnik the way the update panel work, it just update the controls that are inside of it. since the EventsDictionary is not inside of it (and i dont think it can), it is not persisted...
try to replace the ViewState["EventsDictionary"] with Session["EventsDictionary"]
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24834276
"I got the solution"
you got it yourself or I helped???
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24834303
If ravifine, found the solution, please share with us and select it as the solution.

If my anser is the solution, select 24817769.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

16 Experts available now in Live!

Get 1:1 Help Now