GridView.RowStyle Propriedade

Definição

Obtém uma referência ao objeto TableItemStyle que permite definir a aparência das linhas de dados em um controle GridView.Gets a reference to the TableItemStyle object that enables you to set the appearance of the data rows in a GridView control.

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

Valor da propriedade

TableItemStyle

Uma referência ao TableItemStyle que representa o estilo de linhas de dados em um controle GridView.A reference to the TableItemStyle that represents the style of the data rows in a GridView control.

Atributos

Exemplos

O exemplo a seguir demonstra como usar a RowStyle propriedade para definir declarativamente o estilo para as linhas de item em um GridView controle.The following example demonstrates how to use the RowStyle property to declaratively define the style for the item rows in a GridView 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>GridView RowStyle and AlternatingRowStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView RowStyle and AlternatingRowStyle Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        runat="server">
                
        <rowstyle backcolor="LightCyan"  
           forecolor="DarkBlue"
           font-italic="true"/>
                    
        <alternatingrowstyle backcolor="PaleTurquoise"  
          forecolor="DarkBlue"
          font-italic="true"/>
                            
      </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="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </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>GridView RowStyle and AlternatingRowStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView RowStyle and AlternatingRowStyle Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        runat="server">
                
        <rowstyle backcolor="LightCyan"  
           forecolor="DarkBlue"
           font-italic="true"/>
                    
        <alternatingrowstyle backcolor="PaleTurquoise"  
          forecolor="DarkBlue"
          font-italic="true"/>
                            
      </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="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </form>
  </body>
</html>

Comentários

Use a RowStyle propriedade para controlar a aparência das linhas de dados em um GridView controle.Use the RowStyle property to control the appearance of the data rows in a GridView control. Quando a AlternatingRowStyle propriedade também é definida, as linhas de dados são exibidas alternando entre as RowStyle configurações e as AlternatingRowStyle configurações.When the AlternatingRowStyle property is also set, the data rows are displayed alternating between the RowStyle settings and the AlternatingRowStyle settings. Esta propriedade é somente leitura; no entanto, você pode definir as propriedades do TableItemStyle objeto retornado.This property is read-only; however, you can set the properties of the TableItemStyle object it returns. As propriedades podem ser definidas declarativamente usando um dos seguintes métodos:The properties can be set declaratively using one of the following methods:

  • Coloque um atributo na marca de abertura do GridView controle no formulário, em Property-Subproperty que Subproperty é uma propriedade do TableItemStyle objeto (por exemplo, RowStyle-ForeColor ).Place an attribute in the opening tag of the GridView control in the form Property-Subproperty, where Subproperty is a property of the TableItemStyle object (for example, RowStyle-ForeColor).

  • Aninhe um <RowStyle> elemento entre as marcas de abertura e de fechamento do GridView controle.Nest a <RowStyle> element between the opening and closing tags of the GridView control.

As propriedades também podem ser definidas programaticamente no formulário Property.Subproperty (por exemplo, RowStyle.ForeColor ).The properties can also be set programmatically in the form Property.Subproperty (for example, RowStyle.ForeColor). As configurações comuns geralmente incluem uma cor de fundo personalizada, cor de primeiro plano e propriedades de fonte.Common settings usually include a custom background color, foreground color, and font properties.

Aplica-se a

Confira também