asp.net.ph

QueryStringParameter Class

System.Web.UI.WebControls Namespace


.NET Framework version 2.0

Binds the value of an HTTP request query string field to a parameter object.

QueryStringParameter Class Members

Collapse   Constructors

Visibility Constructor Parameters
public QueryStringParameter ( )
public QueryStringParameter ( String name , String queryStringField )
public QueryStringParameter ( String name , DbType dbType , String queryStringField )
public QueryStringParameter ( String name , TypeCode type , String queryStringField )

Collapse   Properties

Visibility Name Value Type Accessibility
public QueryStringField String [ Get , Set ]
public ValidateInput Boolean [ Get , Set ]

Collapse   Methods

Visibility Name Parameters Return Type
protected Clone ( ) Parameter

Remarks

You can use the QueryStringParameter class to bind the value of a field passed on an HTTP request query string to a parameter used in a parameterized query or command. The field is retrieved from the QueryString collection. Controls that bind data to the parameter might throw an exception if a QueryStringParameter is specified, but no corresponding query string name/value pair is passed. Similarly, they might display no data if the query string field name is passed with no corresponding value. Set the DefaultValue to avoid these situations where appropriate.

The QueryStringParameter class provides the QueryStringField property, which identifies the name of the query string value to bind to, in addition to those inherited from the Parameter class.

IMPORTANT: The QueryStringParameter does not validate the value passed by the query string in any way; it uses the raw value. In most cases you can validate the value of the QueryStringParameter before it is used by a data source control by handling an event, such as the Selecting, Updating, Inserting, or Deleting event exposed by the data source control you are using. If the value of the parameter does not pass your validation tests, you can cancel the data operation by setting the Cancel property of the associated CancelEventArgs class to true.

Example

The below code demonstrates how to declaratively use a QueryStringParameter when displaying data in a FormView control. You declare and add the QueryStringParameter to the AccessDataSource control's SelectParameters collection, and it binds the value of the given query string field to the parameter placeholder ( PlanId = ? ) of the SelectCommand.

<asp:accessdatasource id = "planDetails" runat = "server"
   datafile = "~/app_data/plans.mdb"
   selectcommand = "SELECT * FROM Plans WHERE PlanId = ?"
   datasourcemode = "datareader">

   <selectparameters>
      <asp:querystringparameter querystringfield = "id" />
   </selectparameters>

</asp:accessdatasource>

<asp:formview id = "fvPlanDetails" runat = "server"
   datasourceid = "planDetails"
   width=95% enableviewstate=false>

   <itemtemplate>
      ... template definition here ...
   </itemtemplate>

</asp:formview>

The following examples show this code in action.

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