CommandField.UpdateImageUrl プロパティ

定義

CommandField フィールドの Update ボタンに表示するイメージの URL を取得または設定します。

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

プロパティ値

CommandField の Update ボタンに表示するイメージの URL。 既定値は空の文字列 ("") です。このプロパティが設定されていないことを示します。

次のコード例では、 プロパティをUpdateImageUrl使用して、コントロールのフィールドの [更新] ボタンに表示するカスタム イメージを指定する方法をCommandFieldGridView示します。 イメージを ButtonType 表示するには、[更新] ボタンの プロパティを に ButtonType.Image 設定する必要があります。


<%@ 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 showeditbutton="true"
            buttontype="Image"
            editimageurl="~\Images\EditButton.jpg"
            cancelimageurl="~\Images\CancelButton.jpg"
            updateimageurl="~\Images\UpdateButton.jpg"
            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="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 showeditbutton="true"
            buttontype="Image"
            editimageurl="~\Images\EditButton.jpg"
            cancelimageurl="~\Images\CancelButton.jpg"
            updateimageurl="~\Images\UpdateButton.jpg"
            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>

注釈

フィールドの CommandField プロパティが ButtonTypeButtonType.Image設定されている場合は、 プロパティをUpdateImageUrl使用して、[更新] ボタンに表示するイメージを指定します。 このイメージは、クライアントのブラウザーがその形式をサポートしている限り、任意のファイル形式 (.jpg、.gif、.bmpなど) にすることができます。

Note

[更新] ボタンの画像を表示する代わりに、最初に プロパティを または ButtonType.LinkButtonType.Button設定してから プロパティをButtonType設定することで、テキストをUpdateText表示できます。

適用対象

こちらもご覧ください