UpdateText Property

CommandField.UpdateText Property


Gets or sets the caption for an Update button in a CommandField field.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public virtual string UpdateText { get; set; }

Property Value

Type: System.String

The caption for an Update button in a CommandField. The default is "Update".

When the ButtonType property of a CommandField field is set to ButtonType.Button or ButtonType.Link, use the UpdateText property to specify the text to display in an Update button.


As an alternative to displaying text for an Update button, you can display an image by first setting the ButtonType property to ButtonType.Image and then setting the UpdateImageUrl property.

The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and ASP.NET Globalization and Localization.

The following code example demonstrates how to use the UpdateText property to specify a custom caption for an Update button displayed in a CommandField field of a GridView control.

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

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

      <h3>CommandField Example</h3>

      <asp:gridview id="CustomersGridView" 

          <asp:commandfield showeditbutton="true"
            edittext="Edit Customer"
            headertext="Edit Controls"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
          <asp:boundfield datafield="City"
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"


      <!-- 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%>"


.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft