ObjectDataSourceView.SelectParameters ObjectDataSourceView.SelectParameters ObjectDataSourceView.SelectParameters ObjectDataSourceView.SelectParameters Property

Definizione

Ottiene l'insieme di parametri che contiene i parametri utilizzati dal metodo SelectMethod.Gets the parameters collection containing the parameters that are used by the SelectMethod method.

public:
 property System::Web::UI::WebControls::ParameterCollection ^ SelectParameters { System::Web::UI::WebControls::ParameterCollection ^ get(); };
public System.Web.UI.WebControls.ParameterCollection SelectParameters { get; }
member this.SelectParameters : System.Web.UI.WebControls.ParameterCollection
Public ReadOnly Property SelectParameters As ParameterCollection

Valore della proprietà

Oggetto ParameterCollection contenente i parametri utilizzati dal metodo specificato dalla proprietà SelectMethod.A ParameterCollection that contains the parameters used by the method specified by the SelectMethod property.

Esempi

Nell'esempio di codice seguente viene illustrato come recuperare un singolo record di dati ObjectDataSource utilizzando un controllo e quindi visualizzare il record di dati DetailsView in un controllo.The following code example demonstrates how to retrieve a single data record using an ObjectDataSource control, and then display the data record in a DetailsView control. Recupera un record dipendente specifico chiamando il GetEmployee metodo della EmployeeLogic classe. ObjectDataSourceThe ObjectDataSource retrieves a specific employee record by calling the GetEmployee method of the EmployeeLogic class. Il GetEmployee metodo richiede un parametro ID dipendente.The GetEmployee method requires an employee ID parameter. Il ObjectDataSource controllo Usa un QueryStringParameter oggetto nella relativa SelectParameters raccolta per passare un ID al GetEmployee metodo.The ObjectDataSource control uses a QueryStringParameter object in its SelectParameters collection to pass an ID to the GetEmployee method.

Per visualizzare l'implementazione di esempio della EmployeeLogic classe e il GetEmployee metodo, vedere ObjectDataSource.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="EmployeeID" querystringfield="empid" defaultvalue="-1" />
          </selectparameters>
        </asp:objectdatasource>

    </form>
  </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB" Assembly="Samples.AspNet.VB" %>
<%@ Page language="vb" %>
<!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 - VB 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.VB.EmployeeLogic" >
          <selectparameters>
            <asp:querystringparameter name="EmployeeID" querystringfield="empid" defaultvalue="-1" />
          </selectparameters>
        </asp:objectdatasource>

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

Commenti

I nomi e i tipi dei parametri contenuti nella SelectParameters raccolta devono corrispondere ai nomi e ai tipi dei parametri presenti nel metodo specificato SelectMethod dalla firma della proprietà.The names and types of the parameters that are contained in the SelectParameters collection must match the names and types of the parameters that are in the method specified by the SelectMethod property signature. Quando si utilizzano controlli associati a dati che forniscono parametri, ad esempio GridView e DetailsView, il ObjectDataSource controllo unisce automaticamente tutti i parametri specificati in modo esplicito nella raccolta con i parametri forniti da controllo con associazione a dati.When working with data-bound controls that supply parameters, such as GridView and DetailsView, the ObjectDataSource control automatically merges any parameters that are explicitly specified in the collection with those parameters that are provided by the data-bound control. Per ulteriori informazioni, vedere ObjectDataSource.SelectMethod.For more information, see ObjectDataSource.SelectMethod.

Si applica a

Vedi anche