Solved

Viewstate changes not persisting while using updatepanel

Posted on 2009-07-09
9
1,914 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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