asp.net.ph

BaseDataList.CellPadding Property

System.Web.UI.WebControls Namespace   BaseDataList Class


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

Syntax


Inline <asp:basedatalist cellpadding = intPixels ... >
Script BaseDataList.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 amount of padding specified is added to all four sides of the cell.

All cells in the same column of a data listing control share the same cell width. Therefore, if the content of one cell is longer than the content other cells in the same column, the padding amount is applied to the widest cell. All other cells in the column are also set with this cell width.

Similarly, all cells in the same row share the same height. The padding amount is applied to the height of the tallest cell in the row. All other cells in the row are set with this cell height. Individual cell sizes cannot be specified.

Example

The sample below shows how to programmatically set the CellPadding property of a DataGrid 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;

      string query = "SELECT Lastname, Firstname, Address, City, Country FROM Employees";
      myGrid.DataSource = fetchData ( query, "northwind" );
      myGrid.DataBind ( );
   }
   myGrid.CellPadding = int.Parse ( PadSelect.SelectedItem.Text );
}
  C# VB

 Show me 

See Also

BaseDataList 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