This documentation is archived and is not being maintained.

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)

[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ControlParameter : 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" "">
<html xmlns="" >
  <head runat="server">
    <title>ASP.NET Example</title>
    <form id="form1" runat="server">

          <asp:listitem selected="True">Sales Representative</asp:listitem>
          <asp:listitem>Sales Manager</asp:listitem>
          <asp:listitem>Vice President, Sales</asp:listitem>

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




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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0