ObjectDataSourceMethodEventArgs.InputParameters 속성

정의

비즈니스 개체 메서드 매개 변수와 해당 값이 들어 있는 컬렉션을 가져옵니다.

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

속성 값

비즈니스 개체 메서드 매개 변수와 해당 값을 나타내는 이름/값 쌍의 IDictionary입니다.

예제

다음 코드 예제에 사용 하는 방법을 보여 줍니다.는 DropDownList 제어 TextBox 컨트롤 및 여러 ObjectDataSource 컨트롤 데이터를 업데이트 합니다. 합니다 DropDownList Northwind 직원의 이름을 표시 하는 동안는 TextBox 컨트롤은 입력 하 고 주소 정보를 업데이트 하는 데 사용 됩니다. 때문에 UpdateParameters 속성을 포함를 ControlParameter 의 선택된 된 값에 바인딩되는 개체를 DropDownList 트리거하는 단추 컨트롤는 Update 메서드는 직원을 선택한 후에 활성화 됩니다.

이 예제에서는 합니다 NorthwindEmployeeUpdating 전에 메서드가 호출 되는 Update 올바른 매개 변수 및 값을 추가 하는 방법은 InputParameters 컬렉션. 매개 변수 및 값 수 있듯이, 동적으로 또는 선언적으로 추가할 수 있습니다.

<%@ 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>

설명

값 또는 참조로 비즈니스 개체 메서드 매개 변수를 전달할 수 있습니다. 사용 하는 경우는 ObjectDataSourceMethodEventHandler 개체를 처리 하는 Selecting, Updating, Inserting, 또는 Deleting 이벤트를 조작할 수 있습니다 액세스를 사용 하 여 이러한 매개 변수는 InputParameters 속성. 이 사전 매개 변수 변경 작업에는 메서드 오버 로드 라고 적용 됩니다. 경우는 DataObjectTypeName 의 속성을 ObjectDataSource 컨트롤이 설정 된이 사전의 항목에 대 한 데이터 개체 속성만 수정할 수 있습니다, 추가 하거나 매개 변수를 제거할 수 없습니다. 자세한 내용은 Delete를 참조하세요.

참조로 전달 되는 매개 변수 반환 됩니다 합니다 OutputParameters 의 속성을 ObjectDataSourceStatusEventArgs 개체입니다.

적용 대상