| System.Web.UI (system.web.dll) | sealed class |
Every control stores view state information in a StateBag provided in the Control.ViewState property, if you enabled the Control.EnableViewState property. View state includes information representing all properties of a control or page and any custom items you added. Information is provided in a key/value collection and is accessed much like the System.Web.SessionState.HttpSessionState or System.Web.Caching.Cache class. You can add a value to the StateBag collection like this: ViewState["NewObject"] = ds;. The StateBag can contain primitive types or full-fledged serializable objects. When retrieving an object, you will have to cast it to the correct type. Also note that you can enumerate through the StateBag collection by using the StateItem enumerator. public sealed class StateBag : IStateManager, IDictionary, ICollection, IEnumerable { // Public Constructors public StateBag( ); public StateBag(bool ignoreCase); // Public Instance Properties public int Count{get; } // implements ICollection public ICollection Keys{get; } // implements System.Collections.IDictionary public object this[string key]{set; get; } public ICollection Values{get; } // implements System.Collections.IDictionary // Public Instance Methods public StateItem Add(string key, object value); public void Clear( ); // implements System.Collections.IDictionary public IDictionaryEnumerator GetEnumerator( ); // implements System.Collections.IDictionary public bool IsItemDirty(string key); public void Remove(string key); public void SetItemDirty(string key, bool dirty); } Returned By Control.ViewState, System.Web.UI.MobileControls.MobileControl.CustomAttributes, System.Web.UI.WebControls.DataGridColumn.ViewState Passed To AttributeCollection.AttributeCollection( ), System.Web.UI.WebControls.Style.Style( ), System.Web.UI.WebControls.TableItemStyle.TableItemStyle( ), System.Web.UI.WebControls.TableStyle.TableStyle( ) |