ObjectDataSourceMethodEventArgs.InputParameters ObjectDataSourceMethodEventArgs.InputParameters ObjectDataSourceMethodEventArgs.InputParameters ObjectDataSourceMethodEventArgs.InputParameters Property

Definition

Ruft eine Auflistung ab, die Parameter der Geschäftsobjektmethode und ihre Werte enthält.Gets a collection that contains business object method parameters and their values.

public:
 property System::Collections::Specialized::IOrderedDictionary ^ InputParameters { System::Collections::Specialized::IOrderedDictionary ^ get(); };
public System.Collections.Specialized.IOrderedDictionary InputParameters { get; }
member this.InputParameters : System.Collections.Specialized.IOrderedDictionary
Public ReadOnly Property InputParameters As IOrderedDictionary

Eigenschaftswert

Ein IDictionary von Name-Wert-Paaren, die die Parameter der Geschäftsobjektmethode und ihre entsprechenden Werte darstellen.An IDictionary of name/value pairs that represent the business object method parameters and their corresponding values.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie ein DropDownList Steuerelement TextBox , Steuerelemente und ObjectDataSource mehrere Steuerelemente zum Aktualisieren von Daten verwendet werden.The following code example demonstrates how to use a DropDownList control, TextBox controls, and several ObjectDataSource controls to update data. Das DropDownList zeigt den Namen eines Northwind-Mitarbeiters an, während TextBox die Steuerelemente verwendet werden, um Adressinformationen einzugeben und zu aktualisieren.The DropDownList displays the name of a Northwind Employee, while the TextBox controls are used to enter and update address information. Da die UpdateParameters -Eigenschaft ein ControlParameter -Objekt enthält, das an DropDownList den ausgewählten Wert des-Steuer Elements gebunden ist, wird Update die Schaltfläche, die die-Methode auslöst, nur aktiviert, nachdem ein Mitarbeiter ausgewählt wurde.Because the UpdateParameters property contains a ControlParameter object that is bound to the selected value of the DropDownList control, the button that triggers the Update method is only enabled after an employee is selected.

In diesem Beispiel wird die NorthwindEmployeeUpdating -Methode vor der Update -Methode aufgerufen, um der-Auflistung die richtigen InputParameters Parameter und Werte hinzuzufügen.In this example, the NorthwindEmployeeUpdating method is called before the Update method to add the correct parameters and values to the InputParameters collection. Sie können die Parameter und Werte dynamisch, wie demonstriert oder deklarativ, hinzufügen.You can add the parameters and values dynamically, as demonstrated, or declaratively.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<%@ Import namespace="Samples.AspNet.CS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

// Add parameters and initialize the user interface
// only if an employee is selected.
private void Page_Load(object sender, EventArgs e)
{
  // Be sure the text boxes are initialized with
  // data from the currently selected employee.
  NorthwindEmployee selectedEmployee = EmployeeLogic.GetEmployee(DropDownList1.SelectedValue);
  if (selectedEmployee != null) {
    AddressBox.Text    = selectedEmployee.Address;
    CityBox.Text       = selectedEmployee.City;
    PostalCodeBox.Text = selectedEmployee.PostalCode;

    Button1.Enabled = true;
  }
  else {
    Button1.Enabled = false;
  }
}

// Press the button to update.
private void Btn_UpdateEmployee (object sender, CommandEventArgs e) {
    ObjectDataSource2.Update();
}

// Dynamically add parameters to the InputParameters collection.
private void NorthwindEmployeeUpdating(object source, ObjectDataSourceMethodEventArgs e) {

  // The names of the parameters are the same as
  // the variable names for the method that is invoked to
  // perform the Update. The InputParameters collection is
  // an IDictionary collection of name/value pairs,
  // not a ParameterCollection.
  e.InputParameters.Add("anID",       DropDownList1.SelectedValue);
  e.InputParameters.Add("anAddress"  ,AddressBox.Text);
  e.InputParameters.Add("aCity"      ,CityBox.Text);
  e.InputParameters.Add("aPostalCode",PostalCodeBox.Text);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>ObjectDataSource - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">

        <!-- The DropDownList is bound to the first ObjectDataSource. -->
        <asp:objectdatasource
          id="ObjectDataSource1"
          runat="server"
          selectmethod="GetAllEmployees"
          typename="Samples.AspNet.CS.EmployeeLogic" />

        <p><asp:dropdownlist
          id="DropDownList1"
          runat="server"
          datasourceid="ObjectDataSource1"
          datatextfield="FullName"
          datavaluefield="EmpID"
          autopostback="True" /></p>

        <!-- The second ObjectDataSource performs the Update. This
             preserves the state of the DropDownList, which otherwise
             would rebind when the DataSourceChanged event is
             raised as a result of an Update operation. -->

        <asp:objectdatasource
          id="ObjectDataSource2"
          runat="server"
          updatemethod="UpdateEmployeeWrapper"
          onupdating="NorthwindEmployeeUpdating"
          typename="Samples.AspNet.CS.EmployeeLogic" />

        <p><asp:textbox
          id="AddressBox"
          runat="server" /></p>

        <p><asp:textbox
          id="CityBox"
          runat="server" /></p>

        <p><asp:textbox
          id="PostalCodeBox"
          runat="server" /></p>

        <asp:button
          id="Button1"
          runat="server"
          text="Update Employee"
          oncommand="Btn_UpdateEmployee" />

    </form>
  </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB" Assembly="Samples.AspNet.VB" %>
<%@ Page language="vb" %>
<%@ Import namespace="Samples.AspNet.VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

' Add parameters and initialize the user interface
' only if an employee is selected.
Private Sub Page_Load(sender As Object, e As EventArgs)

  ' Be sure the text boxes are initialized with
  ' data from the currently selected employee.
  Dim selectedEmployee As NorthwindEmployee
  selectedEmployee = EmployeeLogic.GetEmployee(DropDownList1.SelectedValue)

  If Not selectedEmployee Is Nothing Then
    AddressBox.Text    = selectedEmployee.Address
    CityBox.Text       = selectedEmployee.City
    PostalCodeBox.Text = selectedEmployee.PostalCode

    Button1.Enabled = True
  Else
    Button1.Enabled = False
  End If
End Sub ' Page_Load

' Press the button to update.
Private Sub Btn_UpdateEmployee (sender As Object, e As CommandEventArgs)
    ObjectDataSource2.Update()
End Sub ' Btn_UpdateEmployee

' Dynamically add parameters to the InputParameters collection.
Private Sub NorthwindEmployeeUpdating(source As Object, e As ObjectDataSourceMethodEventArgs)

  ' The names of the parameters are the same as
  ' the variable names for the method that is invoked to
  ' perform the Update. The InputParameters collection is
  ' an IDictionary collection of name/value pairs,
  ' not a ParameterCollection.
  e.InputParameters.Add("anID",       DropDownList1.SelectedValue)
  e.InputParameters.Add("anAddress"  ,AddressBox.Text)
  e.InputParameters.Add("aCity"      ,CityBox.Text)
  e.InputParameters.Add("aPostalCode",PostalCodeBox.Text)

End Sub ' NorthwindEmployeeUpdating

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>ObjectDataSource - VB Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">

        <!-- The DropDownList is bound to the first ObjectDataSource. -->
        <asp:objectdatasource
          id="ObjectDataSource1"
          runat="server"
          selectmethod="GetAllEmployees"
          typename="Samples.AspNet.VB.EmployeeLogic" />

        <p><asp:dropdownlist
          id="DropDownList1"
          runat="server"
          datasourceid="ObjectDataSource1"
          datatextfield="FullName"
          datavaluefield="EmpID"
          autopostback="True" /></p>

        <!-- The second ObjectDataSource performs the Update. This
             preserves the state of the DropDownList, which otherwise
             would rebind when the DataSourceChanged event is
             raised as a result of an Update operation. -->

        <asp:objectdatasource
          id="ObjectDataSource2"
          runat="server"
          updatemethod="UpdateEmployeeWrapper"
          onupdating="NorthwindEmployeeUpdating"
          typename="Samples.AspNet.VB.EmployeeLogic" />

        <p><asp:textbox
          id="AddressBox"
          runat="server" /></p>

        <p><asp:textbox
          id="CityBox"
          runat="server" /></p>

        <p><asp:textbox
          id="PostalCodeBox"
          runat="server" /></p>

        <asp:button
          id="Button1"
          runat="server"
          text="Update Employee"
          oncommand="Btn_UpdateEmployee" />

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

Hinweise

Parameter können als Verweis oder als Wert an die Geschäftsobjekt Methode übermittelt werden.Parameters can be passed to the business object method by reference or by value. ObjectDataSourceMethodEventHandler Wenn Sie ein-Objekt verwenden, um Selectingdie UpdatingEreignisse Inserting,, Deleting oder zu behandeln, können Sie mithilfe der InputParameters -Eigenschaft auf diese Parameter zugreifen und diese bearbeiten.If you use an ObjectDataSourceMethodEventHandler object to handle the Selecting, Updating, Inserting, or Deleting events, you can access and manipulate these parameters using the InputParameters property. Alle Änderungen an den Parametern in diesem Wörterbuch beeinflussen, welche Methoden Überladung für den Vorgang aufgerufen wird.Any changes to the parameters in this dictionary will affect which method overload is called for the operation. Wenn die DataObjectTypeName -Eigenschaft ObjectDataSource des-Steuer Elements festgelegt ist, können Sie nur die Datenobjekt Eigenschaften für die Elemente in diesem Wörterbuch ändern. Parameter können nicht hinzugefügt oder entfernt werden.When the DataObjectTypeName property of the ObjectDataSource control is set, you can modify only the data object properties for the items in this dictionary; you cannot add or remove parameters. Weitere Informationen finden Sie unter Delete.For more information, see Delete.

Parameter, die als Verweis übermittelt werden, werden OutputParameters in der- ObjectDataSourceStatusEventArgs Eigenschaft des-Objekts zurückgegeben.Parameters that are passed by reference are returned in the OutputParameters property of the ObjectDataSourceStatusEventArgs object.

Gilt für: