System.Web.UI.WebControls Namespace
.NET Framework version 2.0
Binds the value of a property of a Control to a parameter object.
The ControlParameter class is used to bind the value of a control property, such as SelectedValue or SelectedIndex, to a parameter 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 base 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 example demonstrates how to use a ControlParameter object to bind data displayed in a GridView control to the selected item of a DropDownList control. The ControlParameter object is added to the FilterParameters collection of the AccessDataSource control on the form.
<asp:accessdatasource id = "plans" runat = "server"
datafile = "~/app_data/plans.mdb"
selectcommand = "SELECT * FROM Plans"
filterexpression = "Type='{0}'">
<filterparameters>
<asp:controlparameter controlid = "typesSelect" propertyname = "SelectedValue" />
</filterparameters>
</asp:accessdatasource>
Below are other examples that demonstrate how to use a ControlParameter object in different scenarios to selectively filter the data display.
Using Parameters with Data Source Controls