Export (0) Print
Expand All

ObjectDataSource.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 SelectMethod method.

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 SelectMethod method.

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 Using Parameters with the ObjectDataSource Control.

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

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

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#" %>
<html>
  <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#" %>
<html>
  <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 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:
© 2014 Microsoft