Solved

Viewstate changes not persisting while using updatepanel

Posted on 2009-07-09
9
1,918 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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 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