System.Web.UI.WebControls.ParameterCollection Class

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

See Also: ParameterCollection Members


[System.ComponentModel.Editor("System.Web.UI.Design.WebControls.ParameterCollectionEditor, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public class ParameterCollection : System.Web.UI.StateManagedCollection


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

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

The System.Web.UI.StateManagedCollection.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 erload:System.Web.UI.WebControls.ParameterCollection.Add, ParameterCollection.Insert(int, Parameter), ParameterCollection.Remove(Parameter), and ParameterCollection.RemoveAt(int) methods.

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


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.


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


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


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


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


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


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


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


Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions:
Since: .NET 2.0