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

CommandField クラス

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

データ バインド コントロールで選択、編集、挿入、または削除の各操作を実行するコマンド ボタンを表示する、特殊なフィールドを表します。

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

Public Class CommandField
    Inherits ButtonFieldBase
public class CommandField : ButtonFieldBase
public ref class CommandField : public
 ButtonFieldBase
public class CommandField extends ButtonFieldBase
public class CommandField extends
 ButtonFieldBase
解説解説

CommandField クラスは、データ バインド コントロール (GridView および DetailsView など) で使用される特殊なフィールドで、削除、編集、挿入、または選択の各操作を実行するコマンド ボタンを表示します。これらの操作を実行するコマンド ボタンは、次の表に示すプロパティを使用して表示または非表示にできます。

プロパティ

説明

ShowDeleteButton

データ バインド コントロール内のレコードごとに、CommandField フィールドの Delete ボタンを表示または非表示にします。Delete ボタンを使用すると、ユーザーはデータ ソースからレコードを削除できます。

ShowEditButton

データ バインド コントロール内のレコードごとに、CommandField フィールドの Edit ボタンを表示または非表示にします。Edit ボタンを使用すると、ユーザーはデータ ソースのレコードを編集できます。ユーザーが特定のレコードの Edit ボタンをクリックすると、Edit ボタンは Update ボタンと Cancel ボタンに置き換わります。その他のコマンド ボタンもすべて非表示になります。

ShowInsertButton

CommandField フィールドの New ボタンを表示または非表示にします。New ボタンを使用すると、ユーザーはデータ ソースに新しいレコードを挿入できます。ユーザーが New ボタンをクリックすると、Insert ボタンと Cancel ボタンに置き換わります。その他のコマンド ボタンもすべて非表示になります。

ShowSelectButton

データ バインド コントロール内のレコードごとに、CommandField フィールドの Select ボタンを表示または非表示にします。Select ボタンを使用すると、ユーザーはデータ バインド コントロール内のレコードを選択できます。

また、ShowCancelButton プロパティを設定することにより、レコードが編集モードまたは挿入モードのときに表示される Cancel ボタンを表示または非表示にすることもできます。

CommandField フィールドは、それが使用されているデータ バインド コントロールによって表示が異なります。たとえば、CommandField フィールドは、GridView コントロールでは列として表示され、DetailsView コントロールでは行として表示されます。

表示するボタンの種類を指定するには、ButtonType プロパティを使用します。ButtonType プロパティが ButtonType.Button または ButtonType.Link に設定されている場合、次の表に示すプロパティを設定して、ボタンに表示するテキストを指定できます。

コマンド ボタンまたはリンク ボタンを表示する代わりに、ButtonType プロパティを ButtonType.Image に設定し、次の表に示すプロパティを設定して、イメージ ボタンを表示できます。

既定では、ユーザーが CommandField フィールドでボタンをクリックすると、ページのすべての検証コントロールで検証が実行されます。ボタンをクリックしたときに検証が行われないようにするには、CausesValidation プロパティを false に設定します。

Visible プロパティを false に設定すると、データ バインド コントロールの CommandField フィールドを非表示にできます。

CommandField フィールドを使用すると、ヘッダー セクションおよびフッター セクションをカスタマイズできます。ヘッダー セクションまたはフッター セクションにキャプションを表示するには、HeaderText プロパティまたは FooterText プロパティをそれぞれ設定します。ヘッダー セクションにテキストを表示する代わりに、HeaderImageUrl プロパティを設定してイメージを表示できます。CommandField オブジェクトのヘッダー セクションを非表示にするには、ShowHeader プロパティを false に設定します。

フィールドの各部分にスタイル プロパティを設定することにより、CommandField オブジェクトの外観 (フォントの色や背景色など) をカスタマイズすることもできます。さまざまなスタイル プロパティの一覧を次の表に示します。

使用例使用例

CommandField フィールドを使用してコントロールを表示し、GridView コントロール内のレコードを編集する方法を次のコード例に示します。

<%@ Page language="VB" %>

<html>
  <body>
    <form runat="server">
      
      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showeditbutton="true"
            headertext="Edit Controls"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </columns>
        
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"
  
        selectcommand="Select [CustomerID], [CompanyName], [Address],
 [City], [PostalCode], [Country] From [Customers]"
        updatecommand="Update Customers Set CompanyName=@CompanyName,
 Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID
 = @CustomerID)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

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

<html>
  <body>
    <form runat="server">
      
      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showeditbutton="true"
            headertext="Edit Controls"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </columns>
        
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City],
 [PostalCode], [Country] From [Customers]"
        updatecommand="Update Customers Set CompanyName=@CompanyName, Address=@Address,
 City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID = @CustomerID)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

CancelText、EditText、および UpdateText の各プロパティを使用して、編集コントロールのテキストをカスタマイズする方法を次のコード例に示します。

<%@ Page language="VB" %>

<html>
  <body>
    <form runat="server">
      
      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showeditbutton="true"
            edittext="Edit Customer"
            canceltext="Discard"
            updatetext="Revise"
            headertext="Edit Controls"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </columns>
        
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"
  
        selectcommand="Select [CustomerID], [CompanyName], [Address],
 [City], [PostalCode], [Country] From [Customers]"
        updatecommand="Update Customers Set CompanyName=@CompanyName,
 Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID
 = @CustomerID)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

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

<html>
  <body>
    <form runat="server">
      
      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showeditbutton="true"
            edittext="Edit Customer"
            canceltext="Discard"
            updatetext="Revise"
            headertext="Edit Controls"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </columns>
        
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City],
 [PostalCode], [Country] From [Customers]"
        updatecommand="Update Customers Set CompanyName=@CompanyName, Address=@Address,
 City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID = @CustomerID)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.WebControls.DataControlField
     System.Web.UI.WebControls.ButtonFieldBase
      System.Web.UI.WebControls.CommandField
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CommandField メンバ
System.Web.UI.WebControls 名前空間
GridView
Columns
DetailsView
Fields
BoundField クラス
ButtonField クラス
ButtonFieldBase クラス
CheckBoxField クラス
DataControlField
HyperLinkField
TemplateField
ButtonFieldBase.ButtonType プロパティ
CancelText
DeleteImageUrl
DeleteText
EditImageUrl
EditText
InsertImageUrl
InsertText
NewImageUrl
NewText
SelectImageUrl
SelectText
ShowCancelButton
ShowDeleteButton
ShowEditButton
ShowInsertButton
ShowSelectButton
UpdateImageUrl
UpdateText
ControlStyle
FooterStyle
HeaderStyle
ItemStyle

CommandField コンストラクタ

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

CommandField クラスの新しいインスタンスを初期化します。

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

public CommandField ()
public:
CommandField ()
public CommandField ()
public function CommandField ()
解説解説
使用例使用例

コンストラクタを使用して、ページに CommandField フィールド列を GridView コントロールに動的に追加する方法を次のコード例に示します。

<%@ Page language="VB" AutoEventWireup="False"
 %>  

<script runat="server">

  Sub Page_Load(ByVal sender As
 Object, ByVal e As EventArgs)
 Handles Me.Load

    ' Dynamically generated field columns need to be created only 
    ' the first time the page is loaded.
    If Not IsPostBack Then
    
      ' Create a CommandField object to display a Select button
      ' for each record in the GridView control.
      Dim selectCommandField As New
 CommandField()
      selectCommandField.ShowSelectButton = True
      selectCommandField.SelectText = "Select Company"
      
      ' Create a BoundField object to display the company names.
      Dim lastNameBoundField As New
 BoundField()
      lastNameBoundField.DataField = "au_lname"
      lastNameBoundField.HeaderText = "Last Name"

      ' Create a BoundField object to display a customer's company name.
      Dim nameBoundField As New
 BoundField()
      nameBoundField.DataField = "CompanyName"
      nameBoundField.HeaderText = "Company Name"

      ' Create a BoundField object to display a customer's city.
      Dim cityBoundField As New
 BoundField()
      cityBoundField.DataField = "City"
      cityBoundField.HeaderText = "City"

      ' Add the field columns to the ColumnFields collection of the
      ' GridView control.
      CustomersGridView.Columns.Add(selectCommandField)
      CustomersGridView.Columns.Add(nameBoundField)
      CustomersGridView.Columns.Add(cityBoundField)
      
    End If
      
  End Sub

  Sub CustomersGridView_SelectedIndexChanged(ByVal
 sender As Object, ByVal
 e As EventArgs) Handles CustomersGridView.SelectedIndexChanged
    
    ' Get the value of the company name and city from the appropriate
 cells.
    Dim companyName As String
 = CustomersGridView.SelectedRow.Cells(1).Text
    Dim city As String =
 CustomersGridView.SelectedRow.Cells(2).Text
   
    Message.Text = "You selected " & companyName
 & " located in " & city & "."
    
  End Sub

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>CommandField Constructor Example</h3>

      <asp:label id="Message" 
        forecolor="Red"
        runat="server"/>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="False"
        runat="server">                
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"
  
        selectcommand="Select [CustomerID], [CompanyName], [City]
 From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

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

<script runat="server">

  void Page_Load(Object sender, EventArgs e)
  {
    // Dynamically generated field columns need to be created only 
    // the first time the page is loaded.
    if (!IsPostBack)
    {
      // Create a CommandField object to display a Select button
      // for each record in the GridView control.
      CommandField selectCommandField = new CommandField();
      selectCommandField.ShowSelectButton = true;
      selectCommandField.SelectText = "Select Company"; 
      
      // Create a BoundField object to display the company names.
      BoundField lastNameBoundField = new BoundField();
      lastNameBoundField.DataField = "au_lname";
      lastNameBoundField.HeaderText = "Last Name";

      // Create a BoundField object to display a customer's company
 name.
      BoundField nameBoundField = new BoundField();
      nameBoundField.DataField = "CompanyName";
      nameBoundField.HeaderText = "Company Name";

      // Create a BoundField object to display a customer's city.
      BoundField cityBoundField = new BoundField();
      cityBoundField.DataField = "City";
      cityBoundField.HeaderText = "City";

      // Add the field columns to the ColumnFields collection of the
      // GridView control.
      CustomersGridView.Columns.Add(selectCommandField);
      CustomersGridView.Columns.Add(nameBoundField);
      CustomersGridView.Columns.Add(cityBoundField);
    }
  }

  void CustomersGridView_SelectedIndexChanged(Object sender, EventArgs
 e)
  {
    // Get the value of the company name and city from the appropriate
 cells.
    String companyName = CustomersGridView.SelectedRow.Cells[1].Text;
    String city = CustomersGridView.SelectedRow.Cells[2].Text;
   
    Message.Text = "You selected " + companyName + " located in
 " + city + ".";
  }

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>CommandField Constructor Example</h3>

      <asp:label id="Message" 
        forecolor="Red"
        runat="server"/>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="False"
        onselectedindexchanged="CustomersGridView_SelectedIndexChanged"
 
        runat="server">                
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [City] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CommandField クラス
CommandField メンバ
System.Web.UI.WebControls 名前空間
GridView
Columns
DetailsView
Fields

CommandField プロパティ


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

( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ AccessibleHeaderText  一部のコントロールの AbbreviatedText プロパティ値として表示されるテキストを取得または設定します。 ( DataControlField から継承されます。)
パブリック プロパティ ButtonType  ボタン フィールドに表示するボタンの種類を取得または設定します。 ( ButtonFieldBase から継承されます。)
パブリック プロパティ CancelImageUrl CommandField フィールドの Cancel ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ CancelText CommandField フィールドに表示される Cancel ボタンのキャプションを取得または設定します。
パブリック プロパティ CausesValidation ユーザーが CommandField フィールドのボタンをクリックしたときに検証が実行されるかどうかを示す値を取得または設定します。
パブリック プロパティ ControlStyle  DataControlField オブジェクトに格納されているすべての Web サーバー コントロールのスタイルを取得または設定します。 ( DataControlField から継承されます。)
パブリック プロパティ DeleteImageUrl CommandField フィールドの Delete ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ DeleteText CommandField フィールドの Delete ボタンのキャプションを取得または設定します。
パブリック プロパティ EditImageUrl CommandField フィールドの Edit ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ EditText CommandField フィールドの Edit ボタンのキャプションを取得または設定します。
パブリック プロパティ FooterStyle  データ コントロール フィールドのフッターのスタイルを取得または設定します。 ( DataControlField から継承されます。)
パブリック プロパティ FooterText  データ コントロール フィールドのフッター項目に表示されるテキストを取得または設定します。 ( DataControlField から継承されます。)
パブリック プロパティ HeaderImageUrl  データ コントロール フィールドのヘッダー項目に表示されるイメージの URL を取得または設定します。 ( DataControlField から継承されます。)
パブリック プロパティ HeaderStyle  データ コントロール フィールドのヘッダーのスタイルを取得または設定します。 ( DataControlField から継承されます。)
パブリック プロパティ HeaderText  データ コントロール フィールドのヘッダー項目に表示されるテキストを取得または設定します。 ( DataControlField から継承されます。)
パブリック プロパティ InsertImageUrl CommandField フィールドの Insert ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ InsertText CommandField フィールドの Insert ボタンのキャプションを取得または設定します。
パブリック プロパティ InsertVisible  DataControlField オブジェクトの親データ バインド コントロールが挿入モードの場合に、このオブジェクトが表示されるかどうかを示す値を取得します。 ( DataControlField から継承されます。)
パブリック プロパティ ItemStyle  データ コントロール フィールドで表示されるテキスト ベースの内容のスタイルを取得します。 ( DataControlField から継承されます。)
パブリック プロパティ NewImageUrl CommandField フィールドの New ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ NewText CommandField フィールドの New ボタンのキャプションを取得または設定します。
パブリック プロパティ SelectImageUrl CommandField フィールドの Select ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ SelectText CommandField フィールドの Select ボタンのキャプションを取得または設定します。
パブリック プロパティ ShowCancelButton CommandField フィールドに Cancel ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ ShowDeleteButton CommandField フィールドに Delete ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ ShowEditButton CommandField フィールドに Edit ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ ShowHeader  ButtonFieldBase オブジェクトにヘッダー セクションを表示するかどうかを示す値を取得または設定します。 ( ButtonFieldBase から継承されます。)
パブリック プロパティ ShowInsertButton CommandField フィールドに New ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ ShowSelectButton CommandField フィールドに Select ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ SortExpression  データ ソース コントロールでデータを並べ替えるために使用される並べ替え式を、取得または設定します。 ( DataControlField から継承されます。)
パブリック プロパティ UpdateImageUrl CommandField フィールドの Update ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ UpdateText CommandField フィールドの Update ボタンのキャプションを取得または設定します。
パブリック プロパティ ValidationGroup  ButtonFieldBase オブジェクトのボタンがクリックされたときに検証する検証コントロールのグループの名前を取得または設定します。 ( ButtonFieldBase から継承されます。)
パブリック プロパティ Visible  データ コントロール フィールドを表示するかどうかを示す値を取得または設定します。 ( DataControlField から継承されます。)
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ Control  DataControlField オブジェクトが関連付けられているデータ コントロールの参照を取得します。 ( DataControlField から継承されます。)
プロテクト プロパティ DesignMode  デザイン時環境で、現在データ コントロール フィールドが表示されているかどうかを示す値を取得します。 ( DataControlField から継承されます。)
プロテクト プロパティ IsTrackingViewState  DataControlField オブジェクトがビューステートへの変更を保存しているかどうかを示す値を取得します。 ( DataControlField から継承されます。)
プロテクト プロパティ ViewState  同一のページに対する複数の要求にわたって、DataControlField オブジェクトのビューステートを保存し、復元できるようにする状態情報のディクショナリを取得します。 ( DataControlField から継承されます。)
参照参照

関連項目

CommandField クラス
System.Web.UI.WebControls 名前空間
GridView
Columns
DetailsView
Fields
BoundField クラス
ButtonField クラス
ButtonFieldBase クラス
CheckBoxField クラス
DataControlField
HyperLinkField
TemplateField
ButtonFieldBase.ButtonType プロパティ
CancelText
DeleteImageUrl
DeleteText
EditImageUrl
EditText
InsertImageUrl
InsertText
NewImageUrl
NewText
SelectImageUrl
SelectText
ShowCancelButton
ShowDeleteButton
ShowEditButton
ShowInsertButton
ShowSelectButton
UpdateImageUrl
UpdateText
ControlStyle
FooterStyle
HeaderStyle
ItemStyle

CommandField メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ExtractValuesFromCell  現在のテーブル セルからデータ コントロール フィールドの値を抽出し、指定した IDictionary コレクションにその値を追加します。 ( DataControlField から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド Initialize  データ コントロール フィールドのインスタンスの基本的な初期化を実行します。 ( DataControlField から継承されます。)
パブリック メソッド InitializeCell オーバーライドされます。 指定の DataControlFieldCell オブジェクトを指定の行の状態に初期化します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  この DataControlField オブジェクトを表す文字列を返します。 ( DataControlField から継承されます。)
パブリック メソッド ValidateSupportsCallback オーバーライドされます。 CommandField オブジェクトに格納されているコントロールがコールバックをサポートしているかどうかを確認します。
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド CloneField  現在の DataControlField 派生オブジェクトのコピーを作成します。 ( DataControlField から継承されます。)
プロテクト メソッド CopyProperties オーバーライドされます。 現在の CommandField オブジェクトのプロパティを、指定した DataControlField オブジェクトにコピーします。
プロテクト メソッド CreateField オーバーライドされます。 空の CommandField オブジェクトを作成します。
プロテクト メソッド Finalize  Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。)
プロテクト メソッド LoadViewState  データ ソース ビューの、以前保存したビューステートを復元します。 ( DataControlField から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object の簡易コピーを作成します。 ( Object から継承されます。)
プロテクト メソッド OnFieldChanged  FieldChanged イベントを発生させます。 ( DataControlField から継承されます。)
プロテクト メソッド SaveViewState  ページがサーバーにポストバックされた時間以降に発生した、DataControlField ビューステートへの変更を保存します。 ( DataControlField から継承されます。)
プロテクト メソッド TrackViewState  DataControlField オブジェクトがそのビューステートの変更を追跡するようにします。それにより、変更をコントロールの ViewState プロパティに格納して、同じページに対する複数の要求にわたって永続化できます。 ( DataControlField から継承されます。)
参照参照

関連項目

CommandField クラス
System.Web.UI.WebControls 名前空間
GridView
Columns
DetailsView
Fields
BoundField クラス
ButtonField クラス
ButtonFieldBase クラス
CheckBoxField クラス
DataControlField
HyperLinkField
TemplateField
ButtonFieldBase.ButtonType プロパティ
CancelText
DeleteImageUrl
DeleteText
EditImageUrl
EditText
InsertImageUrl
InsertText
NewImageUrl
NewText
SelectImageUrl
SelectText
ShowCancelButton
ShowDeleteButton
ShowEditButton
ShowInsertButton
ShowSelectButton
UpdateImageUrl
UpdateText
ControlStyle
FooterStyle
HeaderStyle
ItemStyle

CommandField メンバ

データ バインド コントロールで選択、編集、挿入、または削除の各操作を実行するコマンド ボタンを表示する、特殊なフィールドを表します。

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CommandField CommandField クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ AccessibleHeaderText  一部のコントロールの AbbreviatedText プロパティ値として表示されるテキストを取得または設定します。(DataControlField から継承されます。)
パブリック プロパティ ButtonType  ボタン フィールドに表示するボタンの種類を取得または設定します。(ButtonFieldBase から継承されます。)
パブリック プロパティ CancelImageUrl CommandField フィールドの Cancel ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ CancelText CommandField フィールドに表示される Cancel ボタンのキャプションを取得または設定します。
パブリック プロパティ CausesValidation ユーザーが CommandField フィールドのボタンをクリックしたときに検証が実行されるかどうかを示す値を取得または設定します。
パブリック プロパティ ControlStyle  DataControlField オブジェクトに格納されているすべての Web サーバー コントロールのスタイルを取得または設定します。(DataControlField から継承されます。)
パブリック プロパティ DeleteImageUrl CommandField フィールドの Delete ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ DeleteText CommandField フィールドの Delete ボタンのキャプションを取得または設定します。
パブリック プロパティ EditImageUrl CommandField フィールドの Edit ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ EditText CommandField フィールドの Edit ボタンのキャプションを取得または設定します。
パブリック プロパティ FooterStyle  データ コントロール フィールドのフッターのスタイルを取得または設定します。(DataControlField から継承されます。)
パブリック プロパティ FooterText  データ コントロール フィールドのフッター項目に表示されるテキストを取得または設定します。(DataControlField から継承されます。)
パブリック プロパティ HeaderImageUrl  データ コントロール フィールドのヘッダー項目に表示されるイメージの URL を取得または設定します。(DataControlField から継承されます。)
パブリック プロパティ HeaderStyle  データ コントロール フィールドのヘッダーのスタイルを取得または設定します。(DataControlField から継承されます。)
パブリック プロパティ HeaderText  データ コントロール フィールドのヘッダー項目に表示されるテキストを取得または設定します。(DataControlField から継承されます。)
パブリック プロパティ InsertImageUrl CommandField フィールドの Insert ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ InsertText CommandField フィールドの Insert ボタンのキャプションを取得または設定します。
パブリック プロパティ InsertVisible  DataControlField オブジェクトの親データ バインド コントロールが挿入モードの場合に、このオブジェクトが表示されるかどうかを示す値を取得します。(DataControlField から継承されます。)
パブリック プロパティ ItemStyle  データ コントロール フィールドで表示されるテキスト ベースの内容のスタイルを取得します。(DataControlField から継承されます。)
パブリック プロパティ NewImageUrl CommandField フィールドの New ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ NewText CommandField フィールドの New ボタンのキャプションを取得または設定します。
パブリック プロパティ SelectImageUrl CommandField フィールドの Select ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ SelectText CommandField フィールドの Select ボタンのキャプションを取得または設定します。
パブリック プロパティ ShowCancelButton CommandField フィールドに Cancel ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ ShowDeleteButton CommandField フィールドに Delete ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ ShowEditButton CommandField フィールドに Edit ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ ShowHeader  ButtonFieldBase オブジェクトにヘッダー セクションを表示するかどうかを示す値を取得または設定します。(ButtonFieldBase から継承されます。)
パブリック プロパティ ShowInsertButton CommandField フィールドに New ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ ShowSelectButton CommandField フィールドに Select ボタンが表示されるかどうかを示す値を取得または設定します。
パブリック プロパティ SortExpression  データ ソース コントロールでデータを並べ替えるために使用される並べ替え式を、取得または設定します。(DataControlField から継承されます。)
パブリック プロパティ UpdateImageUrl CommandField フィールドの Update ボタンに表示するイメージの URL を取得または設定します。
パブリック プロパティ UpdateText CommandField フィールドの Update ボタンのキャプションを取得または設定します。
パブリック プロパティ ValidationGroup  ButtonFieldBase オブジェクトのボタンがクリックされたときに検証する検証コントロールのグループの名前を取得または設定します。(ButtonFieldBase から継承されます。)
パブリック プロパティ Visible  データ コントロール フィールドを表示するかどうかを示す値を取得または設定します。(DataControlField から継承されます。)
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ Control  DataControlField オブジェクトが関連付けられているデータ コントロールの参照を取得します。(DataControlField から継承されます。)
プロテクト プロパティ DesignMode  デザイン時環境で、現在データ コントロール フィールドが表示されているかどうかを示す値を取得します。(DataControlField から継承されます。)
プロテクト プロパティ IsTrackingViewState  DataControlField オブジェクトがビューステートへの変更を保存しているかどうかを示す値を取得します。(DataControlField から継承されます。)
プロテクト プロパティ ViewState  同一のページに対する複数の要求にわたって、DataControlField オブジェクトのビューステートを保存し、復元できるようにする状態情報のディクショナリを取得します。(DataControlField から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド ExtractValuesFromCell  現在のテーブル セルからデータ コントロール フィールドの値を抽出し、指定した IDictionary コレクションにその値を追加します。 (DataControlField から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド Initialize  データ コントロール フィールドのインスタンスの基本的な初期化を実行します。 (DataControlField から継承されます。)
パブリック メソッド InitializeCell オーバーライドされます。 指定の DataControlFieldCell オブジェクトを指定の行の状態に初期化します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  この DataControlField オブジェクトを表す文字列を返します。 (DataControlField から継承されます。)
パブリック メソッド ValidateSupportsCallback オーバーライドされます。 CommandField オブジェクトに格納されているコントロールがコールバックをサポートしているかどうかを確認します。
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド CloneField  現在の DataControlField 派生オブジェクトのコピーを作成します。 (DataControlField から継承されます。)
プロテクト メソッド CopyProperties オーバーライドされます。 現在の CommandField オブジェクトのプロパティを、指定した DataControlField オブジェクトにコピーします。
プロテクト メソッド CreateField オーバーライドされます。 空の CommandField オブジェクトを作成します。
プロテクト メソッド Finalize  Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。)
プロテクト メソッド LoadViewState  データ ソース ビューの、以前保存したビューステートを復元します。 (DataControlField から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object の簡易コピーを作成します。 (Object から継承されます。)
プロテクト メソッド OnFieldChanged  FieldChanged イベントを発生させます。 (DataControlField から継承されます。)
プロテクト メソッド SaveViewState  ページがサーバーにポストバックされた時間以降に発生した、DataControlField ビューステートへの変更を保存します。 (DataControlField から継承されます。)
プロテクト メソッド TrackViewState  DataControlField オブジェクトがそのビューステートの変更を追跡するようにします。それにより、変更をコントロールの ViewState プロパティに格納して、同じページに対する複数の要求にわたって永続化できます。 (DataControlField から継承されます。)
参照参照

関連項目

CommandField クラス
System.Web.UI.WebControls 名前空間
GridView
Columns
DetailsView
Fields
BoundField クラス
ButtonField クラス
ButtonFieldBase クラス
CheckBoxField クラス
DataControlField
HyperLinkField
TemplateField
ButtonFieldBase.ButtonType プロパティ
CancelText
DeleteImageUrl
DeleteText
EditImageUrl
EditText
InsertImageUrl
InsertText
NewImageUrl
NewText
SelectImageUrl
SelectText
ShowCancelButton
ShowDeleteButton
ShowEditButton
ShowInsertButton
ShowSelectButton
UpdateImageUrl
UpdateText
ControlStyle
FooterStyle
HeaderStyle
ItemStyle



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「CommandField」の関連用語

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

   

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



CommandFieldのページの著作権

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

©2026 GRAS Group, Inc.RSS