asp.net.ph

GridView.CellPadding Property

System.Web.UI.WebControls Namespace   GridView Class


.NET Framework version 2.0

Sets or retrieves the amount of space between the contents of the cell and its borders.

Syntax


Inline <asp:gridview cellpadding = intPixels ... >
Script GridView.CellPadding [ = intPixels ]

Property Value


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.

Remarks

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 GridView 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.

Example

The sample below shows how to programmatically set the CellPadding property of a GridView 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 );
}
  C# VB

 Show me 

See Also

GridView Members   CellSpacing   GridLines Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph