StateBag.Add Method (String, Object)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Adds a new StateItem object to the StateBag object. If the item already exists in the StateBag object, this method updates the value of the item.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

member Add : 
        key:string *
        value:Object -> StateItem


Type: System.String

The attribute name for the StateItem.

Type: System.Object

The value of the item to add to the StateBag.

Return Value

Type: System.Web.UI.StateItem

Returns a StateItem that represents the object added to view state.

Exception Condition

key is null.

- or -

The number of characters in key is 0.

The following code example demonstrates using the Add method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top