FormViewModeEventArgsとは? わかりやすく解説

FormViewModeEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

ModeChanging イベントデータ提供します

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

Public Class FormViewModeEventArgs
    Inherits CancelEventArgs
Dim instance As FormViewModeEventArgs
public class FormViewModeEventArgs : CancelEventArgs
public ref class FormViewModeEventArgs : public
 CancelEventArgs
public class FormViewModeEventArgs extends
 CancelEventArgs
public class FormViewModeEventArgs extends
 CancelEventArgs
解説解説

FormView コントロール編集挿入、および読み取り専用各モード間の切り替え行おうとすると、実際にモードが変わる前に ModeChanging イベント発生します。これにより、このイベント発生するたびにカスタム ルーチン (FormView コントロール特定のモード用に構成したり、モード変更キャンセルしたりするなど) を実行するイベント処理メソッドを提供できます

FormViewInsertEventArgs オブジェクトイベント処理メソッド渡されることにより、FormView コントロール変更後モード確認したり、ユーザー編集操作挿入操作キャンセルした結果として ModeChanging イベント発生したかどうか確認したできますまた、モード変更キャンセルする必要があることを示すこともできます新しモード確認するには、NewMode プロパティ使用しますまた、NewMode プロパティ使用してプログラムによって FormViewMode 列挙値のいずれかに設定することで、変更後別のモード指定することもできますユーザー編集操作挿入操作キャンセルした結果としてこのイベント発生したかどうか確認するには、CancelingEdit プロパティ使用しますモード変更キャンセルするには、Cancel プロパティtrue設定します

イベント処理詳細については、「イベント利用」を参照してください

FormViewModeEventArgs クラスインスタンス初期プロパティ値の一覧については、FormViewModeEventArgs コンストラクタトピック参照してください

使用例使用例

ModeChanging イベントイベント処理メソッド渡される FormViewModeEventArgs オブジェクト使用してFormView コントロール編集モード移行するときにページ行を非表示にする方法次の例に示します

<%@ Page language="VB" %>

<script runat="server">

  Sub EmployeeFormView_ModeChanging(ByVal sender
 As Object, ByVal e As
 FormViewModeEventArgs)

    ' Use the NewMode property to determine the mode to which the 
    ' FormView control is transitioning.
    Select Case e.NewMode
   
      Case FormViewMode.Edit
        ' Hide the pager row and clear the Label control
        ' when transitioning to edit mode.
        EmployeeFormView.AllowPaging = False
        MessageLabel.Text = ""

      Case FormViewMode.ReadOnly
        ' Display the pager row and confirmation message
        ' when transitioning to edit mode.
        EmployeeFormView.AllowPaging = True
        If e.CancelingEdit Then
        
          MessageLabel.Text = "Update canceled."
        
        Else
        
          MessageLabel.Text = "Update completed."
        
        End If
        
      Case FormViewMode.Insert
        ' Cancel the mode change if the FormView
        ' control attempts to transition to insert 
        ' mode.
        e.Cancel = True

      Case Else
        MessageLabel.Text = "Unsupported mode."

    End Select

  End Sub

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>FormViewModeEventArgs Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        emptydatatext="No employees found."
        onmodechanging="EmployeeFormView_ModeChanging"
  
        runat="server">
        
        <itemtemplate>
          <table>
            <tr>
              <td rowspan="6">
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>'
 
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <%# Eval("FirstName") %> <%#
 Eval("LastName") %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <%# Eval("Title") %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Hire Date:</b>                
 
              </td>
              <td>
                <%# Eval("HireDate","{0:d}")
 %>
              </td>
            </tr>
            <tr height="150" valign="top">
              <td>
                <b>Address:</b>
              </td>
              <td>
                <%# Eval("Address") %><br/>
                <%# Eval("City") %> <%# Eval("Region")
 %>
                <%# Eval("PostalCode") %><br/>
                <%# Eval("Country") %>   
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="Edit"
                  text="Edit"
                  commandname="Edit"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <edititemtemplate>
          <table>
            <tr>
              <td rowspan="6">
                <asp:image id="EmployeeEditImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>'
 
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <asp:textbox id="FirstNameUpdateTextBox"
                  text='<%# Bind("FirstName") %>'
                  runat="server"/>
                <asp:textbox id="LastNameUpdateTextBox"
                  text='<%# Bind("LastName") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <asp:textbox id="TitleUpdateTextBox"
                  text='<%# Bind("Title") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td>
                <b>Hire Date:</b>                
 
              </td>
              <td>
                <asp:textbox id="HireDateUpdateTextBox"
                  text='<%# Bind("HireDate", "{0:d}")
 %>'
                  runat="server"/>
              </td>
            </tr>
            <tr height="150" valign="top">
              <td>
                <b>Address:</b>
              </td>
              <td>
                <asp:textbox id="AddressUpdateTextBox"
                  text='<%# Bind("Address") %>'
                  runat="server"/>
                <br/>
                <asp:textbox id="CityUpdateTextBox"
                  text='<%# Bind("City") %>'
                  runat="server"/> 
                <asp:textbox id="RegionUpdateTextBox"
                  text='<%# Bind("Region") %>'
                  width="40"
                  runat="server"/>
                <asp:textbox id="PostalCodeUpdateTextBox"
                  text='<%# Bind("PostalCode") %>'
                  width="60"
                  runat="server"/>
                <br/>
                <asp:textbox id="CountryUpdateTextBox"
                  text='<%# Bind("Country") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="UpdateButton"
                  text="Update"
                  commandname="Update"
                  runat="server"/>
                <asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </edititemtemplate>
                  
      </asp:formview>
      
      <br/><br/>
      
      <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>
          
      <!-- This example uses Microsoft SQL Server and connects
  -->
      <!-- to the Northwind sample database. Use an ASP.NET
     -->
      <!-- expression to retrieve the connection string
 value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName],
 [Title], [Address], [City], [Region], [PostalCode], [Country], [HireDate], [PhotoPath]
 From [Employees]"
        updatecommand="Update [Employees] Set [LastName]=@LastName,
 [FirstName]=@FirstName, [Title]=@Title, [Address]=@Address, [City]=@City, [Region]=@Region,
 [PostalCode]=@PostalCode, [Country]=@Country Where [EmployeeID]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>
            
    </form>
  </body>
</html>

<%@ Page language="C#" %>

<script runat="server">

  void EmployeeFormView_ModeChanging(Object sender, FormViewModeEventArgs
 e)
  {

    // Use the NewMode property to determine the mode to which the 
    // FormView control is transitioning.
    switch (e.NewMode)
    {
      case FormViewMode.Edit:
        // Hide the pager row and clear the Label control
        // when transitioning to edit mode.
        EmployeeFormView.AllowPaging = false;
        MessageLabel.Text = "";
        break;
      case FormViewMode.ReadOnly:
        // Display the pager row and confirmation message
        // when transitioning to edit mode.
        EmployeeFormView.AllowPaging = true;
        if (e.CancelingEdit)
        {
          MessageLabel.Text = "Update canceled.";
        }
        else
        {
          MessageLabel.Text = "Update completed.";
        }
        break;
      case FormViewMode.Insert:
        // Cancel the mode change if the FormView
        // control attempts to transition to insert 
        // mode.
        e.Cancel = true;
        break;
      default:
        MessageLabel.Text = "Unsupported mode.";
        break;
    }

  }

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>FormViewModeEventArgs Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        emptydatatext="No employees found."
        onmodechanging="EmployeeFormView_ModeChanging"  
        runat="server">
        
        <itemtemplate>
          <table>
            <tr>
              <td rowspan="6">
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <%# Eval("FirstName") %> <%# Eval("LastName")
 %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <%# Eval("Title") %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Hire Date:</b>                 
              </td>
              <td>
                <%# Eval("HireDate","{0:d}") %>
              </td>
            </tr>
            <tr height="150" valign="top">
              <td>
                <b>Address:</b>
              </td>
              <td>
                <%# Eval("Address") %><br/>
                <%# Eval("City") %> <%# Eval("Region")
 %>
                <%# Eval("PostalCode") %><br/>
                <%# Eval("Country") %>   
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="Edit"
                  text="Edit"
                  commandname="Edit"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <edititemtemplate>
          <table>
            <tr>
              <td rowspan="6">
                <asp:image id="EmployeeEditImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <asp:textbox id="FirstNameUpdateTextBox"
                  text='<%# Bind("FirstName") %>'
                  runat="server"/>
                <asp:textbox id="LastNameUpdateTextBox"
                  text='<%# Bind("LastName") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <asp:textbox id="TitleUpdateTextBox"
                  text='<%# Bind("Title") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td>
                <b>Hire Date:</b>                 
              </td>
              <td>
                <asp:textbox id="HireDateUpdateTextBox"
                  text='<%# Bind("HireDate", "{0:d}") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr height="150" valign="top">
              <td>
                <b>Address:</b>
              </td>
              <td>
                <asp:textbox id="AddressUpdateTextBox"
                  text='<%# Bind("Address") %>'
                  runat="server"/>
                <br/>
                <asp:textbox id="CityUpdateTextBox"
                  text='<%# Bind("City") %>'
                  runat="server"/> 
                <asp:textbox id="RegionUpdateTextBox"
                  text='<%# Bind("Region") %>'
                  width="40"
                  runat="server"/>
                <asp:textbox id="PostalCodeUpdateTextBox"
                  text='<%# Bind("PostalCode") %>'
                  width="60"
                  runat="server"/>
                <br/>
                <asp:textbox id="CountryUpdateTextBox"
                  text='<%# Bind("Country") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="UpdateButton"
                  text="Update"
                  commandname="Update"
                  runat="server"/>
                <asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </edititemtemplate>
                  
      </asp:formview>
      
      <br/><br/>
      
      <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value
   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title],
 [Address], [City], [Region], [PostalCode], [Country], [HireDate], [PhotoPath] From
 [Employees]"
        updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName,
 [Title]=@Title, [Address]=@Address, [City]=@City, [Region]=@Region, [PostalCode]=@PostalCode,
 [Country]=@Country Where [EmployeeID]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>
            
    </form>
  </body>
</html>

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.EventArgs
     System.ComponentModel.CancelEventArgs
      System.Web.UI.WebControls.FormViewModeEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormViewModeEventArgs メンバ
System.Web.UI.WebControls 名前空間
FormView クラス
FormViewModeEventHandler
CancelEventArgs
FormView.ModeChanging イベント
Cancel
CancelingEdit
NewMode

FormViewModeEventArgs コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

FormViewModeEventArgs クラス新しインスタンス初期化します。

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

Public Sub New ( _
    mode As FormViewMode, _
    cancelingEdit As Boolean _
)
Dim mode As FormViewMode
Dim cancelingEdit As Boolean

Dim instance As New FormViewModeEventArgs(mode,
 cancelingEdit)
public FormViewModeEventArgs (
    FormViewMode mode,
    bool cancelingEdit
)
public:
FormViewModeEventArgs (
    FormViewMode mode, 
    bool cancelingEdit
)
public FormViewModeEventArgs (
    FormViewMode mode, 
    boolean cancelingEdit
)
public function FormViewModeEventArgs (
    mode : FormViewMode, 
    cancelingEdit : boolean
)

パラメータ

mode

FormViewMode 列挙値の 1 つ

cancelingEdit

ユーザー編集操作キャンセルした結果として ModeChanging イベント発生したことを示す場合trueそれ以外場合false

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormViewModeEventArgs クラス
FormViewModeEventArgs メンバ
System.Web.UI.WebControls 名前空間
FormView クラス
FormViewModeEventHandler
FormView.ModeChanging イベント
CancelingEdit
NewMode

FormViewModeEventArgs プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

FormViewModeEventArgs クラス
System.Web.UI.WebControls 名前空間
FormView クラス
FormViewModeEventHandler
CancelEventArgs
FormView.ModeChanging イベント
Cancel
CancelingEdit
NewMode

FormViewModeEventArgs メソッド


FormViewModeEventArgs メンバ

ModeChanging イベントデータ提供します

FormViewModeEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド FormViewModeEventArgs FormViewModeEventArgs クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

FormViewModeEventArgs クラス
System.Web.UI.WebControls 名前空間
FormView クラス
FormViewModeEventHandler
CancelEventArgs
FormView.ModeChanging イベント
Cancel
CancelingEdit
NewMode



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

辞書ショートカット

すべての辞書の索引

「FormViewModeEventArgs」の関連用語

FormViewModeEventArgsのお隣キーワード
検索ランキング

   

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



FormViewModeEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS