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

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

ButtonColumn.CommandName プロパティ

System.Web.UI.WebControls.ButtonColumn オブジェクトボタンクリックされたときに実行するコマンドを表す文字列を取得または設定します

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

Public Overridable Property
 CommandName As String
Dim instance As ButtonColumn
Dim value As String

value = instance.CommandName

instance.CommandName = value
public virtual string CommandName { get;
 set; }
/** @property */
public String get_CommandName ()

/** @property */
public void set_CommandName (String value)
public function get CommandName
 () : String

public function set CommandName
 (value : String)

プロパティ
ButtonColumnボタンクリックされたときに実行するコマンドを表す文字列。既定値空の文字列 ("") です。

解説解説
使用例使用例

CommandName プロパティ使用してコマンド名とボタン関連付ける方法次のコード例示します次にクリックされたボタンコマンド名は、ItemCommand イベントイベント ハンドラプログラムによって判断され適切なアクション実行されます。

<%@ Page Language="VB" %>

<script runat="server">

    Protected Sub Page_Init(ByVal
 sender As Object, ByVal
 e As EventArgs)
        ' Create dynamic column to add to Columns collection.
        Dim AddColumn As New
 ButtonColumn
        AddColumn.HeaderText = "Add Item"
        AddColumn.Text = "Add"
        AddColumn.CommandName = "Add"
        AddColumn.ButtonType = ButtonColumnType.PushButton

        ' Add column to Columns collection.
        ItemsGrid.Columns.AddAt(0, AddColumn)
    End Sub


    Protected Sub ItemsGrid_ItemCommand(ByVal
 source As Object, ByVal
 e As DataGridCommandEventArgs)
        If e.CommandName = "Add"
 Then
            ' Add logic for addition operation here.
            TextBox1.Text = "Added"          
        End If
    End Sub
    
</script>
<html>
  <head id="Head1" runat="server">
    <title>Untitled Page</title>
  </head>
  <body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server"
 Text="Button" /><br />
        <asp:DataGrid 
          ID="ItemsGrid" 
          runat="server" 
          DataSourceID="CustomersSqlDataSource" 
          AutoGenerateColumns="true" 
          OnItemCommand="ItemsGrid_ItemCommand" />
        
        <!-- This example uses Microsoft SQL Server and connects
 -->
        <!-- to the Northwind sample database.            
       -->
        <asp:sqldatasource id="CustomersSqlDataSource"
  
          selectcommand="Select [CustomerID], [CompanyName], [ContactName],
 [ContactTitle] From [Customers]"
          connectionstring="<%$ ConnectionStrings:NorthWindConnection%>"
          runat="server">
        </asp:sqldatasource>

    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>

<script runat="server">

    protected void Page_Init(object sender,
 EventArgs e)
    {
       // Create dynamic column to add to Columns collection.
       ButtonColumn AddColumn = new ButtonColumn();
       AddColumn.HeaderText="Add Item"; 
       AddColumn.Text="Add";
       AddColumn.CommandName="Add";
       AddColumn.ButtonType = ButtonColumnType.PushButton;

       // Add column to Columns collection.
       ItemsGrid.Columns.AddAt(0, AddColumn);
    }


    protected void ItemsGrid_ItemCommand(object
 source, DataGridCommandEventArgs e)
    {
        if (e.CommandName == "Add")
        {
            // Add logic for addition operation here.
            this.TextBox1.Text = "Added";
        }

    }
</script>
<html>
  <head runat="server">
    <title>Untitled Page</title>
  </head>
  <body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button"
 /><br />
        <asp:DataGrid 
          ID="ItemsGrid" 
          runat="server" 
          DataSourceID="CustomersSqlDataSource" 
          AutoGenerateColumns="true" 
          OnItemCommand="ItemsGrid_ItemCommand" />
        
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Northwind sample database.                   -->
        <asp:sqldatasource id="CustomersSqlDataSource"  
          selectcommand="Select [CustomerID], [CompanyName], [ContactName],
 [ContactTitle] From [Customers]"
          connectionstring="<%$ ConnectionStrings:NorthWindConnection%>"
          runat="server">
        </asp:sqldatasource>

    </div>
    </form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ButtonColumn クラス
ButtonColumn メンバ
System.Web.UI.WebControls 名前空間
ItemCommand
String.Empty


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS