DetailsView.HeaderStyle Proprietà

Definizione

Ottiene un riferimento all'oggetto TableItemStyle che consente di impostare l'aspetto della riga dell'intestazione in un controllo DetailsView.

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

Valore della proprietà

TableItemStyle

Un riferimento all'oggetto TableItemStyle che rappresenta lo stile della riga dell'intestazione in un controllo DetailsView.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come usare la HeaderStyle proprietà per specificare le impostazioni del tipo di carattere e dello stile per la riga di intestazione.


<%@ 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 HeaderText Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView HeaderText Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          headertext="Confidential"   
          runat="server">
               
          <fieldheaderstyle backcolor="Navy"
            forecolor="White"/>
            
          <headerstyle forecolor="Red"
            backcolor="LightBlue" 
            font-names="Arial"
            font-size="10"
            font-bold="true"/>
                    
        </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 HeaderText Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView HeaderText Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          headertext="Confidential"   
          runat="server">
               
          <fieldheaderstyle backcolor="Navy"
            forecolor="White"/>
            
          <headerstyle forecolor="Red"
            backcolor="LightBlue" 
            font-names="Arial"
            font-size="10"
            font-bold="true"/>
                    
        </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>

Commenti

La riga di intestazione viene visualizzata nella parte superiore del DetailsView controllo quando la HeaderText proprietà o HeaderTemplate è impostata. Utilizzare la HeaderStyle proprietà per controllare l'aspetto della riga di intestazione in un DetailsView controllo. Questa proprietà è di sola lettura; tuttavia, è possibile impostare le proprietà dell'oggetto TableItemStyle restituito. Le proprietà possono essere impostate in modo dichiarativo nel formato Property-Subproperty, dove Subproperty è una proprietà dell'oggetto TableItemStyle , ad esempio HeaderStyle-ForeColor. Le proprietà possono anche essere impostate a livello di codice nel modulo Property.Subproperty ( ad esempio , HeaderStyle.ForeColor). Le impostazioni comuni in genere includono un colore di sfondo personalizzato, il colore di primo piano e le proprietà del carattere.

Si applica a

Vedi anche