DetailsView.Caption Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur teks untuk dirender dalam elemen keterangan HTML dalam DetailsView kontrol. Properti ini disediakan untuk membuat kontrol lebih mudah diakses oleh pengguna perangkat teknologi bantuan.
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
Nilai Properti
String yang mewakili teks untuk dirender dalam elemen keterangan HTML dalam DetailsView kontrol. Nilai default adalah string kosong ("").
Contoh
Contoh kode berikut menunjukkan cara menggunakan Caption properti untuk menentukan teks untuk elemen keterangan HTML yang DetailsView dirender dalam kontrol.
<%@ 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>
Keterangan
Caption Gunakan properti untuk menentukan teks yang akan dirender dalam elemen keterangan HTML dalam DetailsView kontrol. Teks yang Anda tentukan menyediakan perangkat teknologi bantuan dengan deskripsi tabel yang dapat digunakan untuk membuat kontrol lebih mudah diakses.
Dukungan aksesibilitas tambahan untuk DetailsView kontrol disediakan oleh CaptionAlign properti . CaptionAlign Gunakan properti untuk menentukan perataan elemen keterangan HTML dalam DetailsView kontrol.
Nilai Caption disimpan dalam status tampilan.
Nilai properti ini, ketika diatur, dapat disimpan secara otomatis ke file sumber daya dengan menggunakan alat perancang. Untuk informasi selengkapnya, lihat LocalizableAttribute dan Globalisasi dan Pelokalan.