Compartir a través de


DetailsView.CommandRowStyle Propiedad

Definición

Obtiene una referencia al objeto TableItemStyle que permite establecer el aspecto de una fila de comandos de un control DetailsView.

public:
 property System::Web::UI::WebControls::TableItemStyle ^ CommandRowStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle CommandRowStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.CommandRowStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property CommandRowStyle As TableItemStyle

Valor de propiedad

TableItemStyle

Referencia al objeto TableItemStyle que representa el estilo de una fila de comandos de un control DetailsView.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la CommandRowStyle propiedad para especificar la configuración de fuente y estilo de la fila de comandos del DetailsView 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>DetailsView CommandRowStyle Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView CommandRowStyle Example</h3>

        <asp:detailsview id="CustomerDetailsView"
          datasourceid="DetailsViewSource"
          autogeneraterows="false"  
          datakeynames="CustomerID"     
          gridlines="Both"
          allowpaging="true"     
          runat="server">
          
          <headerstyle backcolor="Navy"
            forecolor="White" />
                      
          <commandrowstyle backcolor="LightCyan"
            font-names="Arial"
            font-size="10"
            font-bold="true"/>
                              
          <fields>
          
            <asp:commandfield ButtonType="Link"
              ShowEditButton="true"/>
            
            <asp:boundfield datafield="CustomerID"
              headertext="Customer ID"
              readonly="true"/>
              
            <asp:boundfield datafield="CompanyName"
              headertext="Company Name"/>
              
            <asp:boundfield datafield="Address"
              headertext="Address"/>
              
            <asp:boundfield datafield="City"
              headertext="City"/>
                  
            <asp:boundfield datafield="PostalCode"
              headertext="Postal Code"/>
              
            <asp:boundfield datafield="Country"
              headertext="Country"/>
              
          </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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </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>DetailsView CommandRowStyle Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView CommandRowStyle Example</h3>

        <asp:detailsview id="CustomerDetailsView"
          datasourceid="DetailsViewSource"
          autogeneraterows="false"  
          datakeynames="CustomerID"     
          gridlines="Both"
          allowpaging="true"     
          runat="server">
          
          <headerstyle backcolor="Navy"
            forecolor="White" />
                      
          <commandrowstyle backcolor="LightCyan"
            font-names="Arial"
            font-size="10"
            font-bold="true"/>
                              
          <fields>
          
            <asp:commandfield ButtonType="Link"
              ShowEditButton="true"/>
            
            <asp:boundfield datafield="CustomerID"
              headertext="Customer ID"
              readonly="true"/>
              
            <asp:boundfield datafield="CompanyName"
              headertext="Company Name"/>
              
            <asp:boundfield datafield="Address"
              headertext="Address"/>
              
            <asp:boundfield datafield="City"
              headertext="City"/>
                  
            <asp:boundfield datafield="PostalCode"
              headertext="Postal Code"/>
              
            <asp:boundfield datafield="Country"
              headertext="Country"/>
              
          </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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"

          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
  </body>
</html>

Comentarios

Utilice la CommandRowStyle propiedad para controlar la apariencia de una fila de comandos en un DetailsView control . Una fila de comandos contiene los botones de comando para realizar operaciones como editar, eliminar e insertar. Esta propiedad es de solo lectura; sin embargo, puede establecer las propiedades del TableItemStyle objeto que devuelve. Las propiedades se pueden establecer mediante declaración en el formato Property-Subproperty, donde Subproperty es una propiedad del TableItemStyle objeto (por ejemplo, CommandRowStyle-ForeColor). Las propiedades también se pueden establecer mediante programación en el formulario Property.Subproperty (por ejemplo, CommandRowStyle.ForeColor). La configuración común suele incluir un color de fondo personalizado, un color de primer plano y propiedades de fuente.

Se aplica a

Consulte también