Este tema aún no ha recibido ninguna valoración - Valorar este tema

CommandField.NewText (Propiedad)

Obtiene o establece el título del botón de nuevo que se muestra en un campo CommandField.

Espacio de nombres: System.Web.UI.WebControls
Ensamblado: System.Web (en system.web.dll)

[LocalizableAttribute(true)] 
public virtual string NewText { get; set; }
/** @property */
public String get_NewText ()

/** @property */
public void set_NewText (String value)

public function get NewText () : String

public function set NewText (value : String)

No aplicable.

Valor de propiedad

Título del botón de nuevo de un campo CommandField. El valor predeterminado es "Nuevo".

Cuando la propiedad ButtonType de un objeto CommandField esté establecida en ButtonType.Button o ButtonType.Link, utilice la propiedad NewText para especificar el texto que se debe mostrar en el botón de nuevo.

NotaNota:

Como alternativa a texto en el botón de nuevo, también se puede mostrar una imagen, estableciendo primero la propiedad ButtonType en ButtonType.Image y, después, la propiedad NewImageUrl.

El valor de esta propiedad, cuando está establecida, se puede guardar automáticamente en un archivo de recursos mediante una herramienta de diseñador. Para obtener más información, vea LocalizableAttribute y Globalización y adaptación en ASP.NET.

En el ejemplo de código siguiente se muestra cómo utilizar la propiedad NewText para especificar un título personalizado que se debe mostrar en el botón de nuevo en un campo CommandField de un control DetailsView.


<%@ 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:detailsview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneraterows="false"
        datakeynames="CustomerID"  
        allowpaging="true" 
        runat="server">
        
        <fields>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="CompanyName"/>
          <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"/>
          <asp:commandfield showinsertbutton="true"
            inserttext="Save"
            newtext="Add New Customer" 
            showheader="true"
            headertext="Add Customer"/>
        </fields>
        
      </asp:detailsview>
            
      <!-- 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]"
        insertcommand="Insert Into [Customers]([CustomerID], [CompanyName], [City], [PostalCode], [Country]) Values (@CustomerID, @CompanyName, @City, @PostalCode, @Country)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>


Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0
¿Te ha resultado útil?
(Caracteres restantes: 1500)
© 2013 Microsoft. Reservados todos los derechos.