asp.net.ph

ControlParameter Class

System.Web.UI.WebControls Namespace


.NET Framework version 2.0

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

ControlParameter Class Members

Collapse   Constructors

Visibility Constructor Parameters
public ControlParameter ( )
public ControlParameter ( String name , String controlID )
public ControlParameter ( String name , String controlID , String propertyName )
public ControlParameter ( String name , DbType dbType , String controlID , String propertyName )
public ControlParameter ( String name , TypeCode type , String controlID , String propertyName )

Collapse   Properties

Visibility Name Value Type Accessibility
public ControlID String [ Get , Set ]
public PropertyName String [ Get , Set ]

Collapse   Methods

Visibility Name Parameters Return Type
protected Clone ( ) Parameter

Remarks

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.

Example

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>
GridView PagerSettings, PagerStyle Example
Run Sample | View Source

Below are other examples that demonstrate how to use a ControlParameter object in different scenarios to selectively filter the data display.

Dynamically Generated ButtonField ImageButtons
Run Sample | View Source
GridView SelectedValue Example
Run Sample | View Source
Using the SqlDataSource.FilterExpression Property
Run Sample | View Source
See Also

Using Parameters with Data Source Controls Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph