ObjectDataSource.SelectParameters Property

Gets the parameters collection that contains the parameters that are used by the method specified by the SelectMethod property.

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

Not applicable.

Property Value

A ParameterCollection that contains the parameters used by the method specified by the SelectMethod property.

The names and types of the parameters that are contained in the SelectParameters collection must match the names and types of the parameters in the method that is specified by the SelectMethod property signature. The parameters in the collection depend on the data in the data-bound control, the parameters that are specified declaratively, and the parameters that are added programmatically. For more information, see the "Parameter Merging" section in Select and Parameters with the ObjectDataSource Control.

NoteNote:

If you are not familiar with the Data Access features in ASP.NET 2.0, you should read some of these topics before continuing:

The SelectParameters property retrieves the SelectParameters property that is contained by the ObjectDataSourceView object that is associated with the ObjectDataSource control.

For more information about object lifetime and method resolution, see SelectMethod.

Security noteSecurity Note:

You should validate any parameter value that you receive from the client. The runtime simply substitutes the parameter value into the method specified by the SelectMethod property.

The following code example demonstrates how to retrieve a single data record using an ObjectDataSource control and display it in a DetailsView control. The ObjectDataSource retrieves a specific employee record by calling the GetEmployee method of the EmployeeLogic class. The GetEmployee method requires an employee ID parameter. The ObjectDataSource control uses a QueryStringParameter object in its SelectParameters collection to pass an ID to the GetEmployee method.

To view the example implementation of the EmployeeLogic class and the GetEmployee method, see ObjectDataSource.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>ObjectDataSource - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">

        <asp:detailsview
          id="DetailsView1"
          runat="server"
          datasourceid="ObjectDataSource1">
        </asp:detailsview>

<!-- Security Note: The ObjectDataSource uses a QueryStringParameter,
     Security Note: which does not perform validation of input from the client.
     Security Note: To validate the value of the QueryStringParameter, handle the Selecting event. -->

        <asp:objectdatasource
          id="ObjectDataSource1"
          runat="server"
          selectmethod="GetEmployee"
          typename="Samples.AspNet.CS.EmployeeLogic" >
          <selectparameters>
            <asp:querystringparameter name="anID" querystringfield="empid" defaultvalue="-1" />
          </selectparameters>
        </asp:objectdatasource>

    </form>
  </body>
</html>

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.jsl" Assembly="Samples.AspNet.jsl" %>
<%@ Page Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>ObjectDataSource - VJ# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">

        <asp:detailsview
          id="DetailsView1"
          runat="server"
          datasourceid="ObjectDataSource1">
        </asp:detailsview>

        <asp:objectdatasource
          id="ObjectDataSource1"
          runat="server"
          selectmethod="GetEmployee"
          typename="Samples.AspNet.jsl.EmployeeLogic" >
          <selectparameters>
            <asp:querystringparameter name="anID" querystringfield="empid" defaultvalue="-1" />
          </selectparameters>
        </asp:objectdatasource>

    </form>
  </body>
</html>

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: