GridView.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 berikut menunjukkan cara menggunakan CellPadding properti untuk secara deklaratif mengatur jumlah ruang 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>GridView CellPadding and CellSpacing Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>GridView CellPadding and CellSpacing Example</h3>
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="true"
emptydatatext="No data available."
cellpadding="10"
cellspacing="5"
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 CellPadding and CellSpacing Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>GridView CellPadding and CellSpacing Example</h3>
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="true"
emptydatatext="No data available."
cellpadding="10"
cellspacing="5"
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>
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 GridView sama memiliki lebar yang sama. Jumlah padding diterapkan ke sel terluas dan semua sel lain dalam kolom memiliki lebar sel ini. 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 memiliki tinggi sel ini. Ukuran sel individual tidak dapat ditentukan.