DetailsView.HeaderText Właściwość

Definicja

Pobiera lub ustawia tekst do wyświetlenia w wierszu nagłówka kontrolki DetailsView .

public:
 virtual property System::String ^ HeaderText { System::String ^ get(); void set(System::String ^ value); };
public virtual string HeaderText { get; set; }
member this.HeaderText : string with get, set
Public Overridable Property HeaderText As String

Wartość właściwości

String

Tekst do wyświetlenia w wierszu nagłówka. Wartość domyślna to pusty ciąg (""), który wskazuje, że ta właściwość nie jest ustawiona.

Przykłady

W poniższym przykładzie kodu pokazano, jak za pomocą HeaderText właściwości określić tekst do wyświetlenia w wierszu nagłówka.


<%@ 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>

Uwagi

Wiersz nagłówka jest wyświetlany w górnej DetailsView części kontrolki, gdy właściwość lub HeaderTemplate jest ustawionaHeaderText. HeaderText Użyj właściwości , aby określić tekst do wyświetlenia w wierszu nagłówka. Aby kontrolować styl wiersza nagłówka, użyj HeaderStyle właściwości . Alternatywnie możesz zdefiniować własny niestandardowy interfejs użytkownika dla wiersza nagłówka, ustawiając HeaderTemplate właściwość zamiast tej właściwości.

Uwaga

HeaderText Jeśli właściwości i HeaderTemplate są ustawione, HeaderTemplate właściwość ma pierwszeństwo.

Wartość jest HeaderText przechowywana w stanie widoku.

Wartość tej właściwości, po ustawieniu, można automatycznie zapisać w pliku zasobów za pomocą narzędzia projektanta. Aby uzyskać więcej informacji, zobacz LocalizableAttribute Globalization and Localization (Globalizacja i lokalizacja).

Dotyczy

Zobacz też