System.Web.UI.HtmlControls Namespace HtmlTable Class
Sets or retrieves the cell padding, in pixels, for an HtmlTable control.
Inline |
<table cellpadding = intPixels ... > |
Script |
HtmlTable.CellPadding [ = intPixels ] |
intPixels |
Integer specifying the amount of space, in pixels, between the contents of a cell and the cell's border. |
The property is read/write with no default value.
Use the CellPadding property to control the spacing between the contents of a cell and the cell's border. The padding amount specified is added to all four sides of the cell.
All cells in a column share the same cell height and width; therefore, the padding is applied evenly to all cells in the column. Individual cell sizes cannot be specified.
The following example shows how to declaratively set the CellPadding property of an HtmlTable control at design time.
<table cellpadding=5 width="92%" runat="server">
<tr>
<th>Table header</th></tr>
<tr>
<td>Table data</td></tr>
</table>
The example below demonstrates how to programmatically set the CellPadding property at run time, depending on user input.
void Page_Load ( object Source, EventArgs e ) {
if ( !IsPostBack ) {
for ( int i=0; i<=30; i+=5 ) {
paddingSelect.Items.Add ( i.ToString ( ) );
}
paddingSelect.Value = "5";
}
myTable.CellPadding = int.Parse ( paddingSelect.Value );
}
Show me
HtmlTable Members CellSpacing