Export (0) Print
Expand All

ParameterCollection Class

Represents a collection of Parameter and Parameter-derived objects that are used by data source controls in advanced data-binding scenarios.

System::Object
  System.Web.UI::StateManagedCollection
    System.Web.UI.WebControls::ParameterCollection

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

public ref class ParameterCollection : public StateManagedCollection

The ParameterCollection type exposes the following members.

  NameDescription
Public methodParameterCollectionInitializes the class for use by an inherited class instance. This constructor can be called only by an inherited class.
Top

  NameDescription
Public propertyCountGets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public propertyItem[Int32]Gets or sets the Parameter object at the specified index in the collection.
Public propertyItem[String]Gets or sets the Parameter object with the specified name in the collection.
Top

  NameDescription
Public methodAdd(Parameter)Appends the specified Parameter object to the end of the collection.
Public methodAdd(String, String)Creates a Parameter object with the specified name and default value, and appends it to the end of the collection.
Public methodAdd(String, DbType, String)Creates a Parameter object with the specified name, database type, and default value, and adds it to the end of the collection.
Public methodAdd(String, TypeCode, String)Creates a Parameter object with the specified name, TypeCode, and default value, and appends it to the end of the collection.
Public methodClearRemoves all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodContainsDetermines whether the ParameterCollection collection contains a specific value
Public methodCopyTo(Array, Int32)Copies the elements of the StateManagedCollection collection to an array, starting at a particular array index. (Inherited from StateManagedCollection.)
Public methodCopyTo(array<Parameter>, Int32)Copies a specified index of a parameter array to the parameter collection.
Protected methodCreateKnownTypeCreates an instance of a default Parameter object. (Overrides StateManagedCollection::CreateKnownType(Int32).)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Protected methodGetKnownTypesGets an array of Parameter types that the ParameterCollection collection can contain. (Overrides StateManagedCollection::GetKnownTypes().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValuesGets an ordered collection of Parameter object names and their corresponding values currently contained by the collection.
Public methodIndexOfDetermines the index of a specified Parameter object in the ParameterCollection collection.
Public methodInsertInserts the specified Parameter object into the ParameterCollection collection at the specified index.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnClearWhen overridden in a derived class, performs additional work before the Clear method removes all items from the collection. (Inherited from StateManagedCollection.)
Protected methodOnClearCompletePerforms additional custom processes after clearing the contents of the collection. (Overrides StateManagedCollection::OnClearComplete().)
Protected methodOnInsertOccurs before the Insert method is called. (Overrides StateManagedCollection::OnInsert(Int32, Object).)
Protected methodOnInsertCompleteOccurs after the Insert method completes. (Overrides StateManagedCollection::OnInsertComplete(Int32, Object).)
Protected methodOnParametersChangedRaises the ParametersChanged event.
Protected methodOnRemoveWhen overridden in a derived class, performs additional work before the Remove or RemoveAt method removes the specified item from the collection. (Inherited from StateManagedCollection.)
Protected methodOnRemoveCompleteOccurs after the Remove method completes. (Overrides StateManagedCollection::OnRemoveComplete(Int32, Object).)
Protected methodOnValidatePerforms additional custom processes when validating a value. (Overrides StateManagedCollection::OnValidate(Object).)
Public methodRemoveRemoves the specified Parameter object from the ParameterCollection collection.
Public methodRemoveAtRemoves the Parameter object at the specified index from the ParameterCollection collection.
Public methodSetDirtyForces the entire StateManagedCollection collection to be serialized into view state. (Inherited from StateManagedCollection.)
Protected methodSetDirtyObjectMarks the specified Parameter object as having changed since the last load or save from view state. (Overrides StateManagedCollection::SetDirtyObject(Object).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodUpdateValuesIterates through the Parameter objects contained by the collection, and calls the Evaluate method on each one.
Top

  NameDescription
Public eventParametersChangedOccurs when one or more Parameter objects contained by the collection changes state.
Top

  NameDescription
Explicit interface implemetationPrivate propertyICollection::CountInfrastructure. Gets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection::IsSynchronizedInfrastructure. Gets a value indicating whether the StateManagedCollection collection is synchronized (thread safe). This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection::SyncRootInfrastructure. Gets an object that can be used to synchronize access to the StateManagedCollection collection. This method returns nullptr in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIEnumerable::GetEnumeratorInfrastructure. Returns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList::AddAdds an item to the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList::ClearInfrastructure. Removes all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList::ContainsDetermines whether the StateManagedCollection collection contains a specific value. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList::IndexOfDetermines the index of a specified item in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList::InsertInserts an item into the StateManagedCollection collection at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList::IsFixedSizeInfrastructure. Gets a value indicating whether the StateManagedCollection collection has a fixed size. This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList::IsReadOnlyInfrastructure. Gets a value indicating whether the StateManagedCollection collection is read-only. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList::ItemInfrastructure. Gets the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList::RemoveRemoves the first occurrence of the specified object from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList::RemoveAtRemoves the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIStateManager::IsTrackingViewStateGets a value indicating whether the StateManagedCollection collection is saving changes to its view state. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager::LoadViewStateRestores the previously saved view state of the StateManagedCollection collection and the IStateManager items it contains. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager::SaveViewStateSaves the changes to the StateManagedCollection collection and each IStateManager object it contains since the time the page was posted back to the server. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager::TrackViewStateCauses the StateManagedCollection collection and each of the IStateManager objects it contains to track changes to their view state so they can be persisted across requests for the same page. (Inherited from StateManagedCollection.)
Top

The ParameterCollection class represents a collection of Parameter objects used in advanced data-binding scenarios with data source controls. The Parameter objects are used to bind the values contained by local Page variables, HTTP cookies, session variables, and other controls' values to data source controls when retrieving, updating, deleting, and inserting data.

Use the ParameterCollection class to programmatically manage a set of Parameter objects. You can add, insert, and remove Parameter objects using the appropriate methods of the ParameterCollection class. To programmatically retrieve Parameter objects from a collection, use one of following methods:

The Count property specifies the total number of items in the collection, and is used to determine the upper bound of the collection. You can add and remove items from the collection by using the Add, Insert, Remove, and RemoveAt methods.

Depending on the implementation and the semantics of a particular data source control, the order in which the parameters are stored in the ParameterCollection collection might be important. For example, when using the SqlDataSource control as an ODBC data source, the order of the Parameter objects in the ParameterCollection collection must be the same as the order of the parameters in the parameterized SQL queries you use. However, when using the SqlDataSource control with Microsoft SQL Server, the order of the Parameter objects are not important.

Security noteSecurity Note

When you use data source controls, values are inserted into command parameters without validation, which is a potential security threat. Use an event in the data source control to validate parameter values before the command is executed. For more information, see Script Exploits Overview.

The following table lists the different parameter classes and how they are used.

Parameter Class

Description

Parameter

The base parameter class. Use it to bind to a local variable or any static string using the DefaultValue property.

ControlParameter

A parameter that can be used to bind to a control's property or method return value.

CookieParameter

A parameter that can be used to bind to the value of a cookie.

FormParameter

A parameter that can be used to bind to an attribute of the current Web Forms page.

QueryStringParameter

A parameter that can be used to bind to a value passed to a Web Forms page on a query string.

SessionParameter

A parameter that can be used to bind to the value of a session variable.

ProfileParameter

A parameter that can be used to bind to the value of an ASP.NET Profile property.

The following code example demonstrates how to use an AccessDataSource control and a FormParameter to display information from a Microsoft Access database in a GridView control. The FormParameter object is added to the SelectParameters collection using the Add method.

Security noteSecurity Note

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft