DetailsView.AlternatingRowStyle Propiedad

Definición

Obtiene una referencia al objeto TableItemStyle que permite establecer el aspecto de las filas de datos alternas en un control DetailsView.

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

Valor de propiedad

Referencia a TableItemStyle que representa el estilo de las filas de datos alternas de un control DetailsView.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la AlternatingRowStyle propiedad para especificar la configuración de fuente y estilo de las filas de datos alternas en el 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 RowStyle and AlternatingRowStyle Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView RowStyle and AlternatingRowStyle Example</h3>
                
        <asp:detailsview id="CustomersView"
          datasourceid="Customers"
          autogeneraterows="true"
          allowpaging="true" 
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
            
          <RowStyle BackColor="LightGray"
            ForeColor="Blue"
            Font-Names="Arial"
            Font-Size="10"
            Font-Italic="true"/>
            
          <AlternatingRowStyle BackColor="White"
            ForeColor="Blue"
            Font-Names="Arial"
            Font-Size="10"
            Font-Italic="true"/>
                    
        </asp:detailsview>
            
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Northwind sample database. -->           
        <asp:SqlDataSource ID="Customers" runat="server" 
          ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
          SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID], [Phone] 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 RowStyle and AlternatingRowStyle Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView RowStyle and AlternatingRowStyle Example</h3>
                
        <asp:detailsview id="CustomersView"
          datasourceid="Customers"
          autogeneraterows="true"
          allowpaging="true" 
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
            
          <RowStyle BackColor="LightGray"
            ForeColor="Blue"
            Font-Names="Arial"
            Font-Size="10"
            Font-Italic="true"/>
            
          <AlternatingRowStyle BackColor="White"
            ForeColor="Blue"
            Font-Names="Arial"
            Font-Size="10"
            Font-Italic="true"/>
                    
        </asp:detailsview>
            
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Northwind sample database. -->           
        <asp:SqlDataSource ID="Customers" runat="server" 
          ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
          SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID], [Phone] FROM [Customers]">
        </asp:SqlDataSource>
            
      </form>
  </body>
</html>

Comentarios

Utilice la AlternatingRowStyle propiedad para controlar la apariencia de las filas de datos alternas en un DetailsView control . Cuando se establece esta propiedad, las filas de datos se muestran alternando entre la RowStyle configuración y la AlternatingRowStyle configuración. 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, AlternatingRowStyle-ForeColor). Las propiedades también se pueden establecer mediante programación en el formulario Property.Subproperty (por ejemplo, AlternatingRowStyle.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