views:

332

answers:

2

Hi,

I would like to ask why setting the size of a TableCell when dynamically rendering the ASP.NET table does not take in effect?

for example:

Table table = new Table();
TableRow row = new TableRow();

TableCell cell = new TableCell;
cell.Width = 30;
cell.Height = 30;

row.Cells.Add(cell);

//.... 10 more cells

table.Rows.Add(row);

why are the size of the cells unchanged?

+1  A: 

you need to size them with a Unit struct. Just providing a numerical value does not indicate what type of unit (pixels, percentage, em, ex, inch, etc) to use.

Unit width = new Unit(30, UnitType.Pixel);
TableCell cell = new TableCell();

cell.Width = width;
Russ Cam
+3  A: 

I am not sure if you can assign the width as cell.Width = 30; try cell.Width = Unit.Pixel(30); also if you are adding multiple rows then may be your width may be because of the width given to a corresponding cell in some other row.

Pranali Desai