Parameter Class
Provides a mechanism that data source controls use to bind to application variables, user identities and choices, and other data. Serves as the base class for all ASP.NET parameter types.
Assembly: System.Web (in System.Web.dll)
System.Web.UI.WebControls.Parameter
System.Web.DynamicData.DynamicControlParameter
System.Web.DynamicData.DynamicQueryStringParameter
System.Web.UI.WebControls.ControlParameter
System.Web.UI.WebControls.CookieParameter
System.Web.UI.WebControls.FormParameter
System.Web.UI.WebControls.ProfileParameter
System.Web.UI.WebControls.QueryStringParameter
System.Web.UI.WebControls.RouteParameter
System.Web.UI.WebControls.SessionParameter
| Name | Description | |
|---|---|---|
![]() | Parameter() | Initializes a new default instance of the Parameter class. |
![]() | Parameter(Parameter) | Initializes a new instance of the Parameter class with the values of the original, specified instance. |
![]() | Parameter(String) | Initializes a new instance of the Parameter class, using the specified name. |
![]() | Parameter(String, DbType) | Initializes a new instance of the Parameter class, using the specified name and database type. |
![]() | Parameter(String, DbType, String) | Initializes a new instance of the Parameter class, using the specified name, the specified database type, and the specified value for its DefaultValue property. |
![]() | Parameter(String, TypeCode) | Initializes a new instance of the Parameter class, using the specified name and type. |
![]() | Parameter(String, TypeCode, String) | Initializes a new instance of the Parameter class, using the specified name, the specified type, and the specified string for its DefaultValue property. |
| Name | Description | |
|---|---|---|
![]() | ConvertEmptyStringToNull | Gets or sets a value indicating whether the value that the Parameter object is bound to should be converted to null if it is String.Empty. |
![]() | DbType | Gets or sets the database type of the parameter. |
![]() | DefaultValue | Specifies a default value for the parameter, should the value that the parameter is bound to be uninitialized when the Evaluate method is called. |
![]() | Direction | Indicates whether the Parameter object is used to bind a value to a control, or the control can be used to change the value. |
![]() | IsTrackingViewState | Gets a value indicating whether the Parameter object is saving changes to its view state. |
![]() | Name | Gets or sets the name of the parameter. |
![]() | Size | Gets or sets the size of the parameter. |
![]() | Type | Gets or sets the type of the parameter. |
![]() | ViewState | Gets a dictionary of state information that allows you to save and restore the view state of a Parameter object across multiple requests for the same page. |
| Name | Description | |
|---|---|---|
![]() | Clone() | Returns a duplicate of the current Parameter instance. |
![]() ![]() | ConvertDbTypeToTypeCode(DbType) | |
![]() ![]() | ConvertTypeCodeToDbType(TypeCode) | |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Evaluate(HttpContext, Control) | Updates and returns the value of the Parameter object. |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetDatabaseType() | Gets the DbType value that is equivalent to the CLR type of the current Parameter instance. |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | LoadViewState(Object) | Restores the data source view's previously saved view state. |
![]() | MemberwiseClone() | |
![]() | OnParameterChanged() | Calls the OnParametersChanged method of the ParameterCollection collection that contains the Parameter object. |
![]() | SaveViewState() | Saves the changes to the Parameter object's view state since the time the page was posted back to the server. |
![]() | SetDirty() | Marks the Parameter object so its state will be recorded in view state. |
![]() | ToString() | Converts the value of this instance to its equivalent string representation.(Overrides Object.ToString().) |
![]() | TrackViewState() | Causes the Parameter object to track changes to its view state so they can be stored in the control's ViewState object and persisted across requests for the same page. |
| Name | Description | |
|---|---|---|
![]() ![]() | ICloneable.Clone() | Returns a duplicate of the current Parameter instance. |
![]() ![]() | IStateManager.LoadViewState(Object) | This API supports the product infrastructure and is not intended to be used directly from your code. Restores the data source view's previously saved view state. |
![]() ![]() | IStateManager.SaveViewState() | This API supports the product infrastructure and is not intended to be used directly from your code. Saves the changes to the Parameter object's view state since the time the page was posted back to the server. |
![]() ![]() | IStateManager.TrackViewState() | This API supports the product infrastructure and is not intended to be used directly from your code. Causes the Parameter object to track changes to its view state so they can be stored in the control's ViewState object and persisted across requests for the same page. |
![]() ![]() | IStateManager.IsTrackingViewState | This API supports the product infrastructure and is not intended to be used directly from your code. Gets a value indicating whether the Parameter object is saving changes to its view state. |
The Parameter class represents a parameter in a parameterized SQL query, a filtering expression, or a business object method call that an ASP.NET data source control uses to select, filter, or modify data. Parameter objects are contained in a ParameterCollection object. Parameter objects are evaluated at run time, to bind the values of the variables they represent to whatever method is used by a data source control to interact with data.
Use classes that derive from Parameter with data source and data-bound controls to build Web-based data applications. These parameter classes are used by data source controls to bind specific kinds of values found in Web applications to placeholders in SQL query strings, business object method parameters, and more. The following table lists parameter types that are included in ASP.NET.
Binds any public property of a Web server control. | |
Binds a form field. | |
Binds a session-state field. | |
Binds a route URL parameter. | |
Binds a cookie field. | |
Binds a query-string parameter. | |
Binds a profile field. |
Extend the base Parameter class when you want to implement your own custom parameter types.
Parameter objects are very simple: they have a Name and a Type property, can be represented declaratively, and can track state across multiple HTTP requests. All parameters support a DefaultValue property, for cases when a parameter is bound to a value, but the value evaluates to null at run time.
When using a collection of Parameter objects with a data source control, their order in the collection might matter. For more information on how parameters are used, see Using Parameters with the SqlDataSource Control and Using Parameters with the ObjectDataSource Control.
The following example shows how to use the selected value of a DropDownList control in the Where clause of a SQL query. The example uses the ControlParameter class, which derives from the ControlParameter class.
The SelectCommand element defines the query with a parameter named "@Title" where the value from DropDownList1 should go. The ControlParameter element specifies that the "@Title" placeholder will be replaced by the value of the SelectedValue property of the DropDownList1 control. The ControlParameter element is added to the SelectParameters collection of the SqlDataSource control.
The following example is like the previous one, but uses code instead of markup. When the page loads the first time, the DropDownList control has no selected value, and the DefaultValue property of the Parameter object is used.
The following code shows the code-behind class for the page in the previous example.
The following code example demonstrates how to extend the Parameter class to create a new parameter type that can be used by data source controls and other controls in data-binding scenarios. A data source control can use a StaticParameter parameter to bind to the value of any object, typically a string, declared on a Web Forms page.
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.







