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

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

DetailsView.CurrentMode プロパティ

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

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

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

Public ReadOnly Property
 CurrentMode As DetailsViewMode
Dim instance As DetailsView
Dim value As DetailsViewMode

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

プロパティ
DetailsViewMode 値の 1 つ

解説解説

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

この値は通常NewDelete、または Cancel の各コマンド ボタンクリックされたときに、DetailsView コントロールによって自動的に設定されます。ChangeMode メソッド使用してモードプログラムによって変更することもできます

DetailsView コントロールモード変更すると、次の表に示すイベント発生します。これにより、イベント発生したときにルーチン実行するカスタム イベント ハンドラ作成できます

使用例使用例

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

<%@ Page Language="VB" %>

<script runat="server">


    Sub CustomerDetailView_ItemCommand(ByVal
 sender As Object, _
      ByVal e As DetailsViewCommandEventArgs)
        ' Clear the error message if the user cancels the edit 
        ' operation.
        If e.CommandName = "Cancel"
 Then
            ErrorMessageLabel.Text = ""
        End If
    End Sub

    Protected Sub CustomerDetailView_PageIndexChanging(
 _
    ByVal sender As Object,
 ByVal e As DetailsViewPageEventArgs)
        ' Cancel the paging operation if the user tries to navigate
 
        ' to another record while in edit mode.
        If CustomerDetailView.CurrentMode = DetailsViewMode.Edit
 Then
            e.Cancel = True
            ' Display an error message.
            ErrorMessageLabel.Text = _
                "You cannot navigate to another record while in
 edit mode."
        End If
    End Sub
</script>

<html>
<body>
    <form id="Form1" runat="server">
        <h3>
            DetailsView CurrentMode Example</h3>
        <asp:DetailsView ID="CustomerDetailView"
 
          DataSourceID="DetailsViewSource" 
          AutoGenerateRows="true"
          AutoGenerateEditButton="true" 
          DataKeyNames="CustomerID" 
          GridLines="Both" 
          AllowPaging="true"
          OnItemCommand="CustomerDetailView_ItemCommand"
 
          runat="server" 
          OnPageIndexChanging="CustomerDetailView_PageIndexChanging">
          
          <HeaderStyle BackColor="Navy" ForeColor="White"
 />
        </asp:DetailsView>
        
        <br />
        
        <asp:Label ID="ErrorMessageLabel" 
          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="DetailsViewSource"
 runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"

          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
</body>
</html>
<%@ Page Language="C#" %>

<script runat="server">


    void CustomerDetailView_ItemCommand(Object sender, 
      DetailsViewCommandEventArgs e)
    {
        // Clear the error message if the user cancels the edit 
        // operation.
        if (e.CommandName == "Cancel")
        {
            ErrorMessageLabel.Text = "";
        }
    }

    protected void CustomerDetailView_PageIndexChanging(
      object sender, DetailsViewPageEventArgs e)
    {
        // Cancel the paging operation if the user tries to 
        // navigate to another record while in edit mode.
        if (CustomerDetailView.CurrentMode == DetailsViewMode.Edit)
        {
            e.Cancel = true;
            // Display an error message.
            ErrorMessageLabel.Text = 
              "You cannot navigate to another record while
 in edit mode.";
        }

    }
</script>

<html>
<body>
    <form id="Form1" runat="server">
        <h3>
            DetailsView CurrentMode Example</h3>
        <asp:DetailsView ID="CustomerDetailView" 
          DataSourceID="DetailsViewSource" 
          AutoGenerateRows="true"
          AutoGenerateEditButton="true" 
          DataKeyNames="CustomerID" 
          GridLines="Both" 
          AllowPaging="true"
          OnItemCommand="CustomerDetailView_ItemCommand" 
          runat="server" 
          OnPageIndexChanging="CustomerDetailView_PageIndexChanging">
          
          <HeaderStyle BackColor="Navy" ForeColor="White"
 />
        </asp:DetailsView>
        
        <br />
        
        <asp:Label ID="ErrorMessageLabel" 
          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="DetailsViewSource" runat="server"
 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DetailsView クラス
DetailsView メンバ
System.Web.UI.WebControls 名前空間
DetailsView.CurrentMode プロパティ
DefaultMode
ChangeMode
ModeChanged
ModeChanging


このページでは「.NET Framework クラス ライブラリ リファレンス」からDetailsView.CurrentMode プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDetailsView.CurrentMode プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDetailsView.CurrentMode プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2025 GRAS Group, Inc.RSS