System.Web.UI.WebControls Namespace FormView Class
.NET Framework version 2.0
Sets or retrieves the amount of space between the contents of the cell and its borders.
Inline |
<asp:formview cellpadding = intPixels ... > |
Script |
FormView.CellPadding [ = intPixels ] |
intPixels |
Integer specifying the amount of space ( in pixels ) between the border and the contents of the cell. |
The property is read/write with a default value of -1, which indicates that no value is specified.
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 the same column of a FormView control have the same width. The padding amount is applied to the widest cell and all other cells in the column are adjusted to that cell width. Similarly, all cells in the same row have the same height. The padding amount is applied to the tallest cell in the row and all other cells in the row are adjusted to that cell height. Individual cell sizes cannot be specified.
To adjust the spacing between cells, use the CellSpacing property.
NOTE: When this property is not set, the default value of the browser is used.
The sample below shows how to programmatically set the CellPadding property of a FormView at run time, depending on user input. The code also demonstrates how to add the user options to a selectable list dynamically.
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
for ( int i=1; i <= 15; i+=2 ) {
PadSelect.Items.Add ( i.ToString ( ) );
}
PadSelect.SelectedIndex = 2;
}
productSpecs.CellPadding = int.Parse ( PadSelect.SelectedValue );
}
Sub Page_Load ( src As Object, e As EventArgs )
If Not IsPostBack Then
Dim i As Integer
For i = 1 To 15 Step 2
PadSelect.Items.Add ( i.ToString ( ) )
Next i
PadSelect.SelectedIndex = 2
End If
productSpecs.CellPadding = Integer.Parse ( PadSelect.SelectedValue )
End Sub |
|
C# |
VB |
Show me
FormView Members CellSpacing GridLines