QueryStringParameter Constructor (String, String)

Note: This constructor is new in the .NET Framework version 2.0.

Initializes a new named instance of the QueryStringParameter class, using the specified string to identify which query string field to bind to.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public:
QueryStringParameter (
	String^ name, 
	String^ queryStringField
)
public QueryStringParameter (
	String name, 
	String queryStringField
)
public function QueryStringParameter (
	name : String, 
	queryStringField : String
)

Parameters

name

The name of the parameter.

queryStringField

The name of the query string field that the parameter object is bound to. The default is Empty.

A QueryStringParameter object created with the QueryStringParameter constructor is initialized with the specified parameter name and string that identifies the query string field that the parameter binds to. Other properties, including Type and Direction, are initialized with default values.

The following code example demonstrates how to create two QueryStringParameter objects with the QueryStringParameter constructor and add them to an AccessDataSource control's SelectParameters collection. A GridView control displays data if the "employee" and "country" query string fields are passed on the query string with valid values.

No code example is currently available or this language may not be supported.
<%@ Page Language="VJ#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
    private void Page_Load(Object sender, System.EventArgs e)
    {
        MyAccessDataSource.get_SelectParameters().Add(
            new QueryStringParameter("employee", "employee"));
        MyAccessDataSource.get_SelectParameters().Add(
            new QueryStringParameter("country", "country"));

    } //Page_Load
</SCRIPT>

<HTML>
  <body>
    <form id="Form1" method="post" runat="server">

        <!-- Use a Query String that includes employee=1&country=USA -->
      <asp:gridview
        id ="GridView1"
        runat="server"
        datasourceid="MyAccessDataSource" />

      <asp:accessdatasource
        id="MyAccessDataSource"
        runat="server"
        datafile="Northwind.mdb"
        selectcommand ="SELECT EmployeeID, LastName, FirstName
          FROM Employees
          WHERE EmployeeID = ? AND Country = ?">
        
      </asp:accessdatasource>
    </form>
  </body>
</HTML>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: