asp.net.ph

GridView.CellSpacing Property

System.Web.UI.WebControls Namespace   GridView Class


.NET Framework version 2.0

Sets or retrieves the amount of space between cells.

Syntax


Inline <asp:gridview cellspacing = intPixels ... >
Script GridView.CellSpacing [ = intPixels ]

Property Value


intPixels Integer specifying the amount of space ( in pixels ) between adjacent cells.

The property is read/write with a default value of -1, which indicates that no value is specified.

Remarks

Use the CellSpacing property to control the spacing between adjacent cells in the GridView control. This spacing is applied both vertically and horizontally. The cell spacing is uniform for the entire control. Individual cell spacing between rows or columns cannot be specified.

NOTE: If you set this property to a value greater than 0, and then set the GridLines property to a value that displays the cell borders, a gap is displayed between the borders of adjacent cells. In this situation, the CellSpacing property controls the size of the gap.

To adjust the spacing between the contents of a cell and the cell's border, use the CellPadding property.

Example

The sample below shows how to programmatically set the CellSpacing 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 ) {
         SpaceSelect.Items.Add ( i.ToString ( ) );
      }
      SpaceSelect.SelectedIndex = 2;
   }
   productSpecs.CellSpacing = int.Parse ( SpaceSelect.SelectedValue );
}
  C# VB

 Show me 

See Also

GridView Members   CellPadding   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