GridView.UseAccessibleHeader 屬性

定義

取得或設定值,指出 GridView 控制項是否以可存取格式呈現其標頭。 這個屬性可讓協助技術裝置的使用者更容易存取控制項。

public:
 virtual property bool UseAccessibleHeader { bool get(); void set(bool value); };
public virtual bool UseAccessibleHeader { get; set; }
member this.UseAccessibleHeader : bool with get, set
Public Overridable Property UseAccessibleHeader As Boolean

屬性值

Boolean

如果 GridView 控制項以可存取格式呈現其標頭則為 true,否則為 false。 預設為 true

範例

下列範例示範如何使用 UseAccessibleHeader 屬性來停用可存取的標頭。


<%@ 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 UseAccessibleHeader Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView UseAccessibleHeader Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true"
        useaccessibleheader="false" 
        runat="server">
        
        <headerstyle backcolor="LightSteelBlue"
          font-names="Verdana"
          font-italic="true"
          font-size="12" 
          forecolor="Blue"/>
                        
      </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 UseAccessibleHeader Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView UseAccessibleHeader Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true"
        useaccessibleheader="false" 
        runat="server">
        
        <headerstyle backcolor="LightSteelBlue"
          font-names="Verdana"
          font-italic="true"
          font-size="12" 
          forecolor="Blue"/>
                        
      </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>

備註

UseAccessibleHeader使用 屬性來指定控制項是否 GridView 以無障礙格式呈現其標頭資料列。 這個屬性可讓協助技術裝置的使用者更容易存取控制項。 根據預設,這個屬性的值是 true ,而且控制項的標頭是使用 <th> 資料表標頭資料格標記來轉譯。 此外, scope="col" 屬性會新增至資料表標頭,以指定標頭會套用至資料行中的所有儲存格。 會保留元素的預設轉 <th> 譯,並以粗體和水準置中方式呈現文字。 開發人員可以使用級聯樣式表單覆寫元素的 <th> 樣式。

如果這個屬性的值是 false ,控制項的標頭會使用 <td> 資料表單元格標記來轉譯。

適用於

另請參閱