System.Web.UI.WebControls.QueryStringParameter Class

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

See Also: QueryStringParameter Members


public class QueryStringParameter : Parameter


You can use the System.Web.UI.WebControls.QueryStringParameter class to bind the value of a field that is passed as part of an HTTP request query string to a parameter that is used in a parameterized query or command. The field is retrieved from the System.Web.HttpRequest.QueryString collection.

Controls that bind data to the parameter might throw an exception if a System.Web.UI.WebControls.QueryStringParameter object is referenced, but no corresponding query-string name/value pair is passed. Similarly, they might display no data if the query-string field name is passed without a corresponding value. To avoid these situations, set the Parameter.DefaultValue property where appropriate.

The System.Web.UI.WebControls.QueryStringParameter class provides the QueryStringParameter.QueryStringField property, which identifies the name of the query string value to bind to. It also provides the properties that are inherited from the System.Web.UI.WebControls.Parameter class.


The System.Web.UI.WebControls.QueryStringParameter class does not validate the value that is passed; it provides the raw value. However, you can validate the value of a System.Web.UI.WebControls.QueryStringParameter object in a data source control. To do so, handle the Selecting, Updating, Inserting, or Deleting event of the data source control and check the parameter value in the event handler. If the value of the parameter does not pass the validation tests, you can cancel the data operation by setting the System.ComponentModel.CancelEventArgs.Cancel property of the associated System.ComponentModel.CancelEventArgs class to true.


Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions:
Since: .NET 2.0