FormView.HeaderText プロパティ

定義

FormView コントロールのヘッダー行に表示するテキストを取得または設定します。

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

プロパティ値

String

ヘッダー行に表示するテキスト。 既定値は空の文字列 ("") です。このプロパティが設定されていないことを示します。

次の例では、プロパティを使用 HeaderText してヘッダー行に表示するテキストを指定する方法を示します。


<%@ 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>FormView HeaderText Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView HeaderText Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true" 
        datakeynames="EmployeeID"
        headertext="Employee Name" 
        runat="server">
        
        <headerstyle horizontalalign="Center"
          forecolor="White"
          backcolor="Blue"/>
           
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>
        
        </itemtemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- 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="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
        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>FormView HeaderText Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView HeaderText Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true" 
        datakeynames="EmployeeID"
        headertext="Employee Name" 
        runat="server">
        
        <headerstyle horizontalalign="Center"
          forecolor="White"
          backcolor="Blue"/>
           
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>
        
        </itemtemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- 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="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

注釈

ヘッダー行は、or HeaderTemplate プロパティが設定されているときにコントロールのFormView上部にHeaderText表示されます。 このプロパティを HeaderText 使用して、ヘッダー行に表示するテキストを指定します。 ヘッダー行のスタイルを制御するには、プロパティを HeaderStyle 使用します。 または、このプロパティの代わりにプロパティを設定 HeaderTemplate することで、ヘッダー行に独自のカスタム ユーザー インターフェイス (UI) を定義することもできます。

注意

プロパティとHeaderTemplateプロパティの両方がHeaderText設定されている場合は、プロパティがHeaderTemplate優先されます。

このプロパティの値を設定すると、デザイナー ツールを使用してリソース ファイルに自動的に保存できます。 詳細については、「グローバリゼーションとローカライズ」を参照してくださいLocalizableAttribute

適用対象

こちらもご覧ください