DetailsView.CellPadding 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 jumlah spasi antara konten sel dan batas sel.
public:
virtual property int CellPadding { int get(); void set(int value); };
public virtual int CellPadding { get; set; }
member this.CellPadding : int with get, set
Public Overridable Property CellPadding As Integer
Nilai Properti
Jumlah spasi, dalam piksel, antara konten sel dan batas sel. Nilai defaultnya adalah -1, yang menunjukkan bahwa properti ini tidak diatur.
Contoh
Contoh kode berikut menunjukkan cara menggunakan CellPadding properti untuk menentukan jumlah penspasian antara konten sel dan batas sel.
<%@ 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 CellPadding and CellSpacing Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>DetailsView CellPadding and CellSpacing Example</h3>
<asp:detailsview id="CustomerDetailView"
datasourceid="DetailsViewSource"
datakeynames="CustomerID"
autogeneraterows="true"
allowpaging="true"
cellpadding="10"
cellspacing="5"
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 CellPadding and CellSpacing Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>DetailsView CellPadding and CellSpacing Example</h3>
<asp:detailsview id="CustomerDetailView"
datasourceid="DetailsViewSource"
datakeynames="CustomerID"
autogeneraterows="true"
allowpaging="true"
cellpadding="10"
cellspacing="5"
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
CellPadding Gunakan properti untuk mengontrol penspasian antara konten sel dan batas sel. Jumlah padding yang ditentukan ditambahkan ke keempat sisi sel.
Semua sel dalam kolom kontrol yang DetailsView sama memiliki lebar yang sama. Jumlah padding diterapkan ke sel terluas dan semua sel lain dalam kolom disesuaikan dengan lebar sel tersebut. Demikian pula, semua sel dalam baris yang sama memiliki tinggi yang sama. Jumlah padding diterapkan ke sel tertinggi di baris dan semua sel lain dalam baris disesuaikan ke tinggi sel tersebut. Ukuran sel individual tidak dapat ditentukan.
Untuk menyesuaikan penspasian antar sel, gunakan CellSpacing properti .