QueryStringParameter.QueryStringField Property
Assembly: System.Web (in system.web.dll)
/** @property */ public String get_QueryStringField () /** @property */ public void set_QueryStringField (String value)
public function get QueryStringField () : String public function set QueryStringField (value : String)
Not applicable.
Property Value
A string that identifies the query string field that the parameter binds to.The QueryStringField identifies a name/value pair that is passed on the query string. While the QueryStringField property identifies the name of the pair, the QueryStringParameter binds to its corresponding value at run time. If the expected query string name/value pair is not passed to the Web Form on the query string, the Evaluate method binds the parameter to the value of the DefaultValue property, if it is set. If the DefaultValue is not set, the Evaluate method fails to bind the parameter to a value.
The following code example demonstrates how to declaratively use a QueryStringParameter with a SqlDataSource control to display data in a ListBox control. The QueryStringField property is set to the name of the expected query string field and the parameter is added to the SelectParameters collection. A DefaultValue is provided in case the expected name/value pair is not passed on the query string.
<asp:ListBox
id ="ListBox1"
runat="server"
DataValueField="EmployeeID"
DataTextField="LastName" />
<asp:SqlDataSource
id="SqlDataSource1"
runat="server"
ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;"
SelectCommand="Select EmployeeID, LastName From Employees where EmployeeID = @empId">
<SelectParameters>
<asp:QueryStringParameter Name="empId" QueryStringField="empId" />
</SelectParameters>
</asp:SqlDataSource>
The following code example demonstrates how to declaratively use a QueryStringParameter with a SqlDataSource control to display data in a GridView control. The QueryStringParameter is added to the SelectParameters collection, along with other parameter objects that are used as an output parameter and return value parameter. Handle values returned from the stored procedure used to retrieve data. This code example is part of a larger example provided for the SqlDataSourceStatusEventArgs class.