SqlDataSource.SelectParameters Property

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

Gets the parameters collection that contains the parameters that are used by the SelectCommand property from the SqlDataSourceView object that is associated with the SqlDataSource control.

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

public ParameterCollection SelectParameters { get; }
/** @property */
public ParameterCollection get_SelectParameters ()

public function get SelectParameters () : ParameterCollection

Property Value

A ParameterCollection that contains the parameters used by the SelectCommand property.

If the SelectCommand property contains a parameterized SQL query, the SelectParameters collection contains any Parameter objects that correspond to the parameter placeholders in the SQL string.

Depending on the ADO.NET provider, the order of the parameters in the SelectParameters collection might be important. The System.Data.OleDb and System.Data.Odbc providers associate the parameters in the collection according to the order that the parameters appear in the parameterized SQL query. The System.Data.SqlClient provider, which is the default ADO.NET provider for the SqlDataSource control, associates the parameters in the collection by matching the name of the parameter with a placeholder alias in the SQL query. For more information on parameterized SQL queries and commands, see Using Parameters with the SqlDataSource Control.

The SelectParameters property retrieves the SelectParameters property that is contained by the SqlDataSourceView object that is associated with the SqlDataSource control.

The following code example demonstrates how to retrieve data from the Northwind database in Microsoft SQL Server by setting the SelectCommand property to an SQL query. The SQL query is parameterized and the placeholder in the SelectCommand property is matched to the ControlParameter object that is added to the SelectParameters collection. The DropDownList control, which the ControlParameter is bound to, acts as a filter for what is displayed in the ListBox control.


Because the parameter is used in a WHERE clause, the use of the SelectParameters property in the code example is functionally equivalent to using the FilterExpression and FilterParameters properties.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <form runat="server">

          <asp:listitem selected>Sales Representative</asp:listitem>
          <asp:listitem>Sales Manager</asp:listitem>
          <asp:listitem>Vice President, Sales</asp:listitem>

          connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
          selectcommand="SELECT LastName FROM Employees WHERE Title = @Title">
              <asp:controlparameter name="Title" controlid="DropDownList1" propertyname="SelectedValue"/>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <FORM runat="server">

          <asp:ListItem Selected>Sales Representative</asp:ListItem>
          <asp:ListItem>Sales Manager</asp:ListItem>
          <asp:ListItem>Vice President, Sales</asp:ListItem>

          ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;"
          SelectCommand="SELECT LastName FROM Employees WHERE Title = @Title">
              <asp:ControlParameter Name="Title" ControlId="DropDownList1" PropertyName="SelectedValue"/>



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