DetailsView.Caption 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定要在 DetailsView 控制項之 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
屬性值
字串,表示要在 DetailsView 控制項的 HTML 標題項目中呈現的文字。 預設值為空字串 ("")。
範例
下列程式代碼範例示範如何使用 Caption 屬性來指定控件中 DetailsView 呈現之 HTML 標題專案的文字。
<%@ 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 Caption and CaptionAlign Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>DetailsView Caption and CaptionAlign Example</h3>
<asp:detailsview id="CustomerDetailView"
datasourceid="DetailsViewSource"
datakeynames="CustomerID"
autogeneraterows="true"
allowpaging="true"
caption="Customer Details"
captionalign="Left"
runat="server">
<headerstyle backcolor="Navy"
forecolor="White"/>
</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 Caption and CaptionAlign Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>DetailsView Caption and CaptionAlign Example</h3>
<asp:detailsview id="CustomerDetailView"
datasourceid="DetailsViewSource"
datakeynames="CustomerID"
autogeneraterows="true"
allowpaging="true"
caption="Customer Details"
captionalign="Left"
runat="server">
<headerstyle backcolor="Navy"
forecolor="White"/>
</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>
備註
Caption使用 屬性可指定要在控件的 HTML 標題項目中呈現的DetailsView文字。 您指定的文字會提供輔助技術裝置,其中包含可用來讓控件更容易存取的數據表描述。
屬性會CaptionAlign提供控制件的其他輔助功能支援DetailsView。 CaptionAlign使用屬性可指定 控制項中 DetailsView HTML 標題專案的對齊方式。
的值 Caption 會儲存在檢視狀態中。
當設定時,此屬性的值可以使用設計工具自動儲存到資源檔。 如需詳細資訊,請參閱 LocalizableAttribute和全球化和當地語系化。