Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > LoadViewState not firing on PostBack

Reply
Thread Tools

LoadViewState not firing on PostBack

 
 
Bill Biddy
Guest
Posts: n/a
 
      01-20-2004


I have search the newsgroups thoroughly and though I have seen several
posts about similar issues I have never seen one that clearly addresses
my problem.

My Control never Gets a LoadViewState Call!

I have a WebControl that is being created as an item template in a
databound templated control (DataList). Within my custom control I have
a complex state Type that wish to add to ViewState. The class that I am
adding to ViewState implements the IStateManager Interface and is
defined as:

//SessionBag contains a SortedList property named List

public class ViewStateBag : SessionBag, IStateManager
{
protected bool _IsTrackingViewState;
protected StateBag _viewstate;

public ViewStateBag()
{
_viewstate = new StateBag();
}

bool IStateManager.IsTrackingViewState
{
get
{
return this._IsTrackingViewState;
}
}

void IStateManager.LoadViewState(object savedState)
{
ArrayList a = new ArrayList();
ArrayList keys = (ArrayList)_viewstate["Keys"];
ArrayList values = (ArrayList)_viewstate["Values"];

for (Int32 x = 0; x < keys.Count; x++)
{
List.Add(keys[x], values[x]);
}
if (savedState != null)
((IStateManager)_viewstate).LoadViewState(savedSta te);
}

object IStateManager.SaveViewState()
{
if( (!((IDictionary)_viewstate).Contain("SkillsStateBa g")) ||
(_viewstate.IsItemDirty("SkillsStateBag")))
{
_viewstate.Clear();
ArrayList keys = new ArrayList();
ArrayList values = new ArrayList();

foreach (DictionaryEntry d in List)
{
keys.Add(d.Key);
values.Add(d.Value);
}

_viewstate["Keys"] = keys;
_viewstate["Values"] = values;
}
_viewstate.SetItemDirty("Keys", true);
_viewstate.SetItemDirty("Values", true);
return ((IStateManager)_viewstate).SaveViewState();
}

void IStateManager.TrackViewState()
{
this._IsTrackingViewState = true;
((IStateManager)_viewstate).TrackViewState();
}
}


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LoadViewState not firing when Control added with AddAt =?Utf-8?B?RGV2aW4gRmVuc3RlcmhlaW0=?= ASP .Net 5 11-26-2009 06:44 PM
Derived TreeNode LoadViewState not firing jsc ASP .Net Web Controls 0 01-12-2009 04:13 PM
LoadViewState not firing / fired in ASP.NET 2.0 J. ASP .Net 0 01-19-2005 09:29 AM
LoadViewState not firing William F. Robertson, Jr. ASP .Net 5 04-16-2004 07:17 PM
LoadViewState override not firing in UserControl Umbaga ASP .Net Building Controls 2 12-10-2003 04:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57