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

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

FormView.CurrentMode プロパティ

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

FormView コントロール現在の日付入力モード取得します

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

Public ReadOnly Property
 CurrentMode As FormViewMode
Dim instance As FormView
Dim value As FormViewMode

value = instance.CurrentMode
public FormViewMode CurrentMode { get; }
public:
property FormViewMode CurrentMode {
    FormViewMode get ();
}
/** @property */
public FormViewMode get_CurrentMode ()
public function get CurrentMode
 () : FormViewMode

プロパティ
FormViewMode 値の 1 つ

解説解説

CurrentMode プロパティ使用してFormView コントロール編集挿入、または読み取り専用いずれのモードであるかを確認しますさまざまなモード値の一覧を次の表に示します

この値は通常NewDelete、または Cancel の各ボタンクリックされたときに、FormView コントロールによって自動的に設定されます。操作への応答として FormView コントロールモード変更すると、次の表のイベント発生します。これにより、イベント発生したときに適切なルーチン実行するカスタム イベント ハンドラ作成できます

メモ   ChangeMode メソッド使用してプログラムによって モード変更した場合、これらのイベント発生しません。

使用例使用例

CurrentMode プロパティ使用してFormView コントロール編集挿入、または読み取り専用いずれのモードであるかを確認する方法次の例に示しますFormView コントロール編集モードになっているときにユーザー別のレコード移動しようとすると、ページング操作キャンセルされます。

<%@ Page language="VB" %>

<script runat="server">

  Sub EmployeeFormView_OnPageIndexChanging(ByVal
 sender As Object, ByVal
 e As FormViewPageEventArgs)

    ' Cancel the paging operation if the user attempts to navigate 
    ' to another record while the FormView control is in edit mode.
 
    If EmployeeFormView.CurrentMode = FormViewMode.Edit Then
    
      e.Cancel = True
      MessageLabel.Text = _
        "Please complete the update operation before navigating
 to another record."
    
    End If
      
  End Sub

  Sub EmployeeFormView_OnModeChanged(ByVal
 sender As Object, ByVal
 e As EventArgs)
 
    ' Clear the message label.
    MessageLabel.Text = ""
    
  End Sub

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>FormView Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        emptydatatext="No employees found."
        onpageindexchanging="EmployeeFormView_OnPageIndexChanging"
 
        onmodechanged="EmployeeFormView_OnModeChanged"
  
        runat="server">
        
        <rowstyle backcolor="LightGreen"
          wrap="false"/>
        <editrowstyle backcolor="LightBlue"
          wrap="false"/>

        <itemtemplate>
          <table>
            <tr>
              <td rowspan="4">
                <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 colspan="2">
                <asp:linkbutton id="Edit"
                  text="Edit"
                  commandname="Edit"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <edititemtemplate>
          <table>
            <tr>
              <td rowspan="4">
                <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 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], [PhotoPath] From [Employees]"
        updatecommand="Update [Employees] Set [LastName]=@LastName,
 [FirstName]=@FirstName, [Title]=@Title Where [EmployeeID]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>
            
    </form>
  </body>
</html>

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

<script runat="server">

  void EmployeeFormView_OnPageIndexChanging(Object sender, FormViewPageEventArgs
 e)
  {
    // Cancel the paging operation if the user attempts to navigate
 
    // to another record while the FormView control is in edit mode.
 
    if (EmployeeFormView.CurrentMode == FormViewMode.Edit)
    {
      e.Cancel = true;
      MessageLabel.Text = 
        "Please complete the update operation before navigating to another record.";
    }
  }

  void EmployeeFormView_OnModeChanged(Object sender, EventArgs
 e)
  {
    // Clear the message label.
    MessageLabel.Text = "";
  }

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>FormView Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        emptydatatext="No employees found."
        onpageindexchanging="EmployeeFormView_OnPageIndexChanging" 
        onmodechanged="EmployeeFormView_OnModeChanged"  
        runat="server">
        
        <rowstyle backcolor="LightGreen"
          wrap="false"/>
        <editrowstyle backcolor="LightBlue"
          wrap="false"/>

        <itemtemplate>
          <table>
            <tr>
              <td rowspan="4">
                <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 colspan="2">
                <asp:linkbutton id="Edit"
                  text="Edit"
                  commandname="Edit"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <edititemtemplate>
          <table>
            <tr>
              <td rowspan="4">
                <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 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],
 [PhotoPath] From [Employees]"
        updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName,
 [Title]=@Title Where [EmployeeID]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>
            
    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormView クラス
FormView メンバ
System.Web.UI.WebControls 名前空間
FormViewMode
DefaultMode
ChangeMode
ModeChanged
ModeChanging



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

辞書ショートカット

すべての辞書の索引

「FormView.CurrentMode プロパティ」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS