ObjectDataSourceMethodEventArgs.InputParameters プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ObjectDataSourceMethodEventArgs.InputParameters プロパティの意味・解説 

ObjectDataSourceMethodEventArgs.InputParameters プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

ビジネス オブジェクトメソッドパラメータとそれらの値を含むコレクション取得します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public ReadOnly Property
 InputParameters As IOrderedDictionary
Dim instance As ObjectDataSourceMethodEventArgs
Dim value As IOrderedDictionary

value = instance.InputParameters
public IOrderedDictionary InputParameters { get;
 }
public:
property IOrderedDictionary^ InputParameters {
    IOrderedDictionary^ get ();
}
/** @property */
public IOrderedDictionary get_InputParameters ()
public function get InputParameters
 () : IOrderedDictionary

プロパティ
ビジネス オブジェクトメソッドパラメータ対応する値を示す、名前/値ペアの IDictionary。

解説解説

パラメータは、参照渡しまたは値渡しで、ビジネス オブジェクトメソッドに渡すことができます。ObjectDataSourceMethodEventHandler オブジェクト使用して Selecting、Updating、Inserting、または Deleting イベント処理する場合に、InputParameters プロパティ使用すると、これらのパラメータアクセスしてパラメータ操作できます。このディクショナリのパラメータ変更加えると、操作でどのメソッド オーバーロード呼び出されるかに影響します。ObjectDataSource コントロールの DataObjectTypeName プロパティ設定すると、変更できるのはこのディクショナリの項目のデータ オブジェクト プロパティのみになり、パラメータ追加または削除はできなくなります詳細については、「Delete」参照してください

参照渡し渡したパラメータは、ObjectDataSourceStatusEventArgs オブジェクトの OutputParameters プロパティ返されます。

使用例使用例

DropDownList コントロールTextBox コントロール、および複数ObjectDataSource コントロール使用してデータ更新する方法次のコード例示しますTextBox コントロールアドレス情報入力更新使用されるのに対しDropDownList は、Northwind Employee の名前を表示します。UpdateParameters プロパティには、 DropDownList コントロール選択された値にバインドされた ControlParameter オブジェクト格納されているため、Update メソッド発生させるボタンは、従業員選択するまで有効になりません。

この例では、InputParameters コレクション正しパラメータと値を追加するために、Update メソッド前に NorthwindEmployeeUpdating メソッド呼び出されます。パラメータと値は、この例で示したように動的に追加することもできますし、宣言によって追加することもできます

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB"
 Assembly="Samples.AspNet.VB"
 %>
<%@ Page language="vb" %>
<%@ Import namespace="Samples.AspNet.VB"
 %>
<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>
  <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>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS"
 Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<%@ Import namespace="Samples.AspNet.CS" %>
<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>
  <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.JSL"
 Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" %>
<%@ Import namespace="Samples.AspNet.JSL" %>
<Script runat="server">
    // Add parameters and initialize the user interface
    // only if an employee is selected.
    private void Page_Load(Object sender, System.EventArgs
 e) throws NorthwindDataException
    {
        // Be sure the text boxes are initialized with
        // data from the currently selected employee.
        NorthwindEmployee selectedEmployee = 
            EmployeeLogic.GetEmployee(DropDownList1.get_SelectedValue());

        if (selectedEmployee != null) {
            AddressBox.set_Text(selectedEmployee.get_Address());
            CityBox.set_Text(selectedEmployee.get_City());
            PostalCodeBox.set_Text(selectedEmployee.get_PostalCode());
            Button1.set_Enabled(true);
        }
        else {
            Button1.set_Enabled(false);
        }
    } //Page_Load

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


    // 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.get_InputParameters().Add("anID", DropDownList1.get_SelectedValue());
        e.get_InputParameters().Add("anAddress", AddressBox.get_Text());
        e.get_InputParameters().Add("aCity", CityBox.get_Text());
        e.get_InputParameters().Add("aPostalCode", PostalCodeBox.get_Text());
    } //NorthwindEmployeeUpdating
</Script>
<html>
  <head>
    <title>ObjectDataSource - VJ# 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.JSL.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.JSL.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>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ObjectDataSourceMethodEventArgs クラス
ObjectDataSourceMethodEventArgs メンバ
System.Web.UI.WebControls 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ObjectDataSourceMethodEventArgs.InputParameters プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ObjectDataSourceMethodEventArgs.InputParameters プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS