GridView.Caption Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the text to render in an HTML caption element in a GridView control. This property is provided to make the control more accessible to users of assistive technology devices.
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
Property Value
A string that represents the text to render in an HTML caption element in a GridView control. The default value is an empty string ("").
Examples
The following example demonstrates how to use the Caption property to specify the caption for a GridView control.
<%@ 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>
Remarks
Use the Caption property to specify the text to render in an HTML caption element in a GridView control. The text that you specify provides assistive technology devices with a description of the table that can be used to make the control more accessible. You can also specify the position at which to render the HTML caption element by using the CaptionAlign property.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and Globalization and Localization.
Applies to
See also
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示