GridView.Caption プロパティ

定義

GridView コントロールの HTML キャプション要素に表示するテキストを取得または設定します。 このプロパティは、補助技術デバイスのユーザーにとって、より使いやすいコントロールを実現するための手段として用意されています。

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

プロパティ値

String

GridView コントロールの HTML キャプション要素に表示されるテキストを表す文字列。 既定値は空の文字列 ("") です。

次の例では、プロパティを使用してコントロールの Caption キャプションを指定する方法を GridView 示します。


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

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true"
        caption="Customer Information Table"
        captionalign="Top"   
        runat="server">                
      </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 Caption and CaptionAlign Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView Caption and CaptionAlign Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true"
        caption="Customer Information Table"
        captionalign="Top"   
        runat="server">                
      </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>

注釈

このプロパティを Caption 使用して、コントロール内の HTML キャプション要素にレンダリングするテキストを GridView 指定します。 指定したテキストは、支援技術デバイスに、コントロールのアクセシビリティを高めるために使用できるテーブルの説明を提供します。 また、プロパティを使用して HTML キャプション要素をレンダリングする位置を CaptionAlign 指定することもできます。

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

適用対象

こちらもご覧ください