ControlParameter.PropertyName Property

 

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

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

[<TypeConverterAttribute(typeof(ControlPropertyNameConverter))>]
member PropertyName : string with get, set

Property Value

Type: System.String

A string that represents the name of a control's property that the ControlParameter binds to.

The PropertyName property identifies the public property of the Control object identified by the ControlID property that the ControlParameter object binds to at run time. PropertyName can be set to a simple string, such as "SelectedValue", or an expression using Eval syntax to identify complex control properties.

While the PropertyName property is optional, typically both ControlID and PropertyName properties are set for the Evaluate method to correctly bind to a control. If you set the ControlID property but not the PropertyName property, the Evaluate method attempts to use the ControlValuePropertyAttribute attribute to identify a default PropertyName property. (It is the responsibility of control authors to specify this attribute.) If this fails, Evaluate throws an ArgumentException exception.

The following table identifies which ASP.NET controls decorate properties with the ControlValuePropertyAttribute attribute.

Control

Property

Calendar

SelectedDate

CheckBox

Checked

DataList

SelectedValue

DetailsView

SelectedValue

FormView

SelectedValue

GridView

SelectedValue

Label

Text

ListControl

SelectedValue

Menu

SelectedValue

TextBox

Text

TreeView

SelectedValue

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 DropDownList control derives from the ListControl control. 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.

No code example is currently available or this language may not be supported.

The following code example demonstrates how to set the ControlID and PropertyName properties to identify the control that a ControlParameter object is bound to. The example populates a ListBox control with values. The SelectedValue property of the ListBox control is used to filter data retrieved by a SqlDataSource control and displayed by a GridView control.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: