QueryStringParameter Class
Binds the value of an HTTP request query-string field to a parameter object.
Assembly: System.Web (in System.Web.dll)
| Name | Description | |
|---|---|---|
![]() | QueryStringParameter() | Initializes a new unnamed instance of the QueryStringParameter class. |
![]() | QueryStringParameter(QueryStringParameter) | Initializes a new instance of the QueryStringParameter class, using the values of the instance that is specified by the original parameter. |
![]() | QueryStringParameter(String, DbType, String) | Initializes a new named instance of the QueryStringParameter class, using the specified query-string field and the data type of the parameter. |
![]() | QueryStringParameter(String, String) | Initializes a new named instance of the QueryStringParameter class, using the specified string to identify which query-string field to bind to. |
![]() | QueryStringParameter(String, TypeCode, String) | Initializes a new named and strongly typed instance of the QueryStringParameter class, using the specified string to identify which query-string field to bind to. |
| Name | Description | |
|---|---|---|
![]() | ConvertEmptyStringToNull | Gets or sets a value indicating whether the value that the Parameter object is bound to should be converted to null if it is String.Empty.(Inherited from Parameter.) |
![]() | DbType | Gets or sets the database type of the parameter.(Inherited from Parameter.) |
![]() | DefaultValue | |
![]() | Direction | |
![]() | IsTrackingViewState | |
![]() | Name | Gets or sets the name of the parameter.(Inherited from Parameter.) |
![]() | QueryStringField | Gets or sets the name of the query-string field that the parameter binds to. |
![]() | Size | Gets or sets the size of the parameter.(Inherited from Parameter.) |
![]() | Type | Gets or sets the type of the parameter.(Inherited from Parameter.) |
![]() | ValidateInput | Gets or sets whether the value of the query string parameter is being validated or not. |
![]() | ViewState |
| Name | Description | |
|---|---|---|
![]() | Clone() | Returns a duplicate of the current QueryStringParameter instance.(Overrides Parameter.Clone().) |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Evaluate(HttpContext, Control) | Updates and returns the value of the QueryStringParameter object.(Overrides Parameter.Evaluate(HttpContext, Control).) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetDatabaseType() | |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | LoadViewState(Object) | Restores the data source view's previously saved view state.(Inherited from Parameter.) |
![]() | MemberwiseClone() | |
![]() | OnParameterChanged() | Calls the OnParametersChanged method of the ParameterCollection collection that contains the Parameter object.(Inherited from Parameter.) |
![]() | SaveViewState() | |
![]() | SetDirty() | |
![]() | ToString() | Converts the value of this instance to its equivalent string representation.(Inherited from Parameter.) |
![]() | TrackViewState() |
| Name | Description | |
|---|---|---|
![]() ![]() | ICloneable.Clone() | |
![]() ![]() | IStateManager.LoadViewState(Object) | This API supports the product infrastructure and is not intended to be used directly from your code. Restores the data source view's previously saved view state.(Inherited from Parameter.) |
![]() ![]() | IStateManager.SaveViewState() | |
![]() ![]() | IStateManager.TrackViewState() | |
![]() ![]() | IStateManager.IsTrackingViewState |
You can use the 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 QueryString collection.
Controls that bind data to the parameter might throw an exception if a 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 DefaultValue property where appropriate.
The QueryStringParameter class provides the QueryStringField property, which identifies the name of the query string value to bind to. It also provides the properties that are inherited from the Parameter class.
Important |
|---|
The QueryStringParameter class does not validate the value that is passed; it provides the raw value. However, you can validate the value of a 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 Cancel property of the associated CancelEventArgs class to true. |
The following example shows how to create a QueryStringParameter object to use as a filter when you display data in a GridView control. You add the QueryStringParameter object to the AccessDataSource control's FilterParameters collection. The parameter object binds the value of the query-string field named country to its FilterExpression string. Because no DefaultValue property is specified for the parameter, if no field named country is passed with the query string, the AccessDataSource control throws a NullReferenceException exception. If a field named country is passed but has no value, the GridView control displays no data.
The following example shows how to create a QueryStringParameter object to display data from an Access database by using a parameterized SQL query. The AccessDataSource object retrieves records that are then displayed in a GridView control. The GridView control is also editable, and lets users update the status of orders in the Northwind Traders Orders table.
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.







