ControlParameter Class

 

Binds the value of a property of a Control to a parameter object.

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

System.Object
  System.Web.UI.WebControls.Parameter
    System.Web.UI.WebControls.ControlParameter

public class ControlParameter : Parameter

NameDescription
System_CAPS_pubmethodControlParameter()

Initializes a new unnamed instance of the ControlParameter class.

System_CAPS_protmethodControlParameter(ControlParameter)

Initializes a new instance of the ControlParameter class with values from the specified instance.

System_CAPS_pubmethodControlParameter(String, DbType, String, String)

Initializes a new instance of the ControlParameter class by using the specified parameter name, database type, control ID, and property name.

System_CAPS_pubmethodControlParameter(String, String)

Initializes a new named instance of the ControlParameter class, using the specified control name to identify which control to bind to.

System_CAPS_pubmethodControlParameter(String, String, String)

Initializes a new named instance of the ControlParameter class, using the specified property name and control name to identify which control to bind to.

System_CAPS_pubmethodControlParameter(String, TypeCode, String, String)

Initializes a new named and strongly typed instance of the ControlParameter class, using the specified property name and control name to identify which control to bind to.

NameDescription
System_CAPS_pubpropertyControlID

Specifies the name of the control that the ControlParameter object binds to.

System_CAPS_pubpropertyConvertEmptyStringToNull

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.(Inherited from Parameter.)

System_CAPS_pubpropertyDbType

Gets or sets the database type of the parameter.(Inherited from Parameter.)

System_CAPS_pubpropertyDefaultValue

Specifies a default value for the parameter, should the value that the parameter is bound to be uninitialized when the Evaluate method is called.(Inherited from Parameter.)

System_CAPS_pubpropertyDirection

Indicates whether the Parameter object is used to bind a value to a control, or the control can be used to change the value.(Inherited from Parameter.)

System_CAPS_protpropertyIsTrackingViewState

Gets a value indicating whether the Parameter object is saving changes to its view state.(Inherited from Parameter.)

System_CAPS_pubpropertyName

Gets or sets the name of the parameter.(Inherited from Parameter.)

System_CAPS_pubpropertyPropertyName

Gets or sets the property name of the control identified by the ControlID property that the ControlParameter object binds to.

System_CAPS_pubpropertySize

Gets or sets the size of the parameter.(Inherited from Parameter.)

System_CAPS_pubpropertyType

Gets or sets the type of the parameter.(Inherited from Parameter.)

System_CAPS_protpropertyViewState

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.(Inherited from Parameter.)

NameDescription
System_CAPS_protmethodClone()

Returns a duplicate of the current ControlParameter instance.(Overrides Parameter.Clone().)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodEvaluate(HttpContext, Control)

Updates and returns the value of the ControlParameter object.(Overrides Parameter.Evaluate(HttpContext, Control).)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetDatabaseType()

Gets the DbType value that is equivalent to the CLR type of the current Parameter instance.(Inherited from Parameter.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodLoadViewState(Object)

Restores the data source view's previously saved view state.(Inherited from Parameter.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnParameterChanged()

Calls the OnParametersChanged method of the ParameterCollection collection that contains the Parameter object.(Inherited from Parameter.)

System_CAPS_protmethodSaveViewState()

Saves the changes to the Parameter object's view state since the time the page was posted back to the server.(Inherited from Parameter.)

System_CAPS_protmethodSetDirty()

Marks the Parameter object so its state will be recorded in view state.(Inherited from Parameter.)

System_CAPS_pubmethodToString()

Converts the value of this instance to its equivalent string representation.(Inherited from Parameter.)

System_CAPS_protmethodTrackViewState()

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.(Inherited from Parameter.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICloneable.Clone()

Returns a duplicate of the current Parameter instance.(Inherited from Parameter.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.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.(Inherited from Parameter.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.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.(Inherited from Parameter.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.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.(Inherited from Parameter.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIStateManager.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.(Inherited from Parameter.)

You can use the ControlParameter class to bind the value of a Control property, such as SelectedValue or SelectedIndex, to a parameter that is used in a parameterized SQL query, business object method, or filtering expression.

The ControlParameter class provides two properties in addition to those inherited from the Parameter class: ControlID and PropertyName. The ControlID property identifies which Control instance to bind to and the PropertyName property identifies the public property of the Control from which the ControlParameter class retrieves a value.

The following code example demonstrates how to use a ControlParameter object to bind data displayed in a ListBox control to the selected value of a DropDownList control in a declarative scenario. The ControlParameter object is added to the SelectParameters collection of the SqlDataSource control on the form, and corresponds to the "@Title" placeholder text in the SelectCommand property.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <p><asp:dropdownlist
          id="DropDownList1"
          runat="server"
          autopostback="True">
          <asp:listitem selected="True">Sales Representative</asp:listitem>
          <asp:listitem>Sales Manager</asp:listitem>
          <asp:listitem>Vice President, Sales</asp:listitem>
      </asp:dropdownlist></p>

      <asp:sqldatasource
          id="SqlDataSource1"
          runat="server"
          connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
          selectcommand="SELECT LastName FROM Employees WHERE Title = @Title">
          <selectparameters>
              <asp:controlparameter name="Title" controlid="DropDownList1" propertyname="SelectedValue"/>
          </selectparameters>
      </asp:sqldatasource>

      <p><asp:listbox
          id="ListBox1"
          runat="server"
          datasourceid="SqlDataSource1"
          datatextfield="LastName">
      </asp:listbox></p>

    </form>
  </body>
</html>

.NET Framework
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.

Return to top
Show: