ASP.NET:TableCell大小问题

jer*_*oft 1 asp.net tablecell

我想问一下为什么在动态呈现ASP.NET表时设置TableCell的大小不起作用?

例如:

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);
Run Code Online (Sandbox Code Playgroud)

为什么细胞的大小不变?

Pra*_*sai 8

我不确定你是否可以指定宽度 cell.Width = 30;

尝试 cell.Width = Unit.Pixel(30);

如果你正在添加,multiple rows那么你的宽度可能会增加,因为cell在某个其他行中给出了相应的宽度.