CommandField.DeleteText プロパティ

定義

CommandField フィールドの Delete ボタンのキャプションを取得または設定します。Gets or sets the caption for a Delete button in a CommandField field.

public:
 virtual property System::String ^ DeleteText { System::String ^ get(); void set(System::String ^ value); };
public virtual string DeleteText { get; set; }
member this.DeleteText : string with get, set
Public Overridable Property DeleteText As String

プロパティ値

String

CommandField の Delete ボタンのキャプション。The caption for a Delete button in a CommandField. 既定値は "削除" です。The default is "Delete".

次のコード例は、プロパティを使用して、 DeleteText コントロールのフィールドに表示される削除ボタンのカスタムキャプションを指定する方法を示して CommandField GridView います。The following code example demonstrates how to use the DeleteText property to specify a custom caption for a Delete button displayed in a CommandField field of a GridView control.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>CommandField Example</title>
</head>
<body>
    <form id="form1" runat="server">
      
      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showdeletebutton="true"
            deletetext="Remove"
            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]"
        deletecommand="Delete [Customers] Where [CustomerID] = @CustomerID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>


<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>CommandField Example</title>
</head>
<body>
    <form id="form1" runat="server">
      
      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showdeletebutton="true"
            deletetext="Remove"
            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]"
        deletecommand="Delete [Customers] Where [CustomerID] = @CustomerID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

注釈

ButtonTypeフィールドのプロパティ CommandField がまたはに設定されている場合は、 ButtonType.Button プロパティを使用して、 ButtonType.Link DeleteText [削除] ボタンに表示するテキストを指定します。When the ButtonType property of a CommandField field is set to ButtonType.Button or ButtonType.Link, use the DeleteText property to specify the text to display for a Delete button.

注意

[削除] ボタンのテキストを表示する代わりに、最初にプロパティをに設定して ButtonType ButtonType.Image から、プロパティを設定することによって、イメージを表示できます DeleteImageUrlAs an alternative to displaying text for a Delete button, you can display an image by first setting the ButtonType property to ButtonType.Image and then setting the DeleteImageUrl property.

このプロパティの値は、設定されると、デザイナーツールを使用してリソースファイルに自動的に保存できます。The value of this property, when set, can be saved automatically to a resource file by using a designer tool. 詳細については、「」 LocalizableAttribute および「 グローバリゼーションとローカリゼーション」を参照してください。For more information, see LocalizableAttribute and Globalization and Localization.

適用対象

こちらもご覧ください