如何设置表格的宽度?

时间:2016-01-25 11:43:15

标签: c# asp.net

Table table = new Table ();        
TableRow row1 = new TableRow();
TableRow row2 = new TableRow();
TableCell cell1_1 = new TableCell { RowSpan = 2,  };           
TableCell cell1_2 = new TableCell
{
    Text = string.Format("<h4>{0}</h4><br />{1}<br/>",
        product.ProductName, "Product No:" + product.Id),
    HorizontalAlign = HorizontalAlign.Left,
};
TableCell cell1_3 = new TableCell { Text = "Unit Price<hr/>"};  
TableCell cell1_4 = new TableCell { Text = "Quantity<hr/>" };            
TableCell cell1_5 = new TableCell { Text = "Product Total<hr/>"};
TableCell cell1_6 = new TableCell();
TableCell cell2_1 = new TableCell();
TableCell cell2_2 = new TableCell { Text = "Rs " + product.Price};
TableCell cell2_3 = new TableCell();            
TableCell cell2_4 = new TableCell { Text = "Rs " + (order.Quantity * product.Price) };
TableCell cell2_5 = new TableCell();

如何设置此表的宽度?当我正在尝试table.Witdh它不工作

2 个答案:

答案 0 :(得分:1)

Table table = new Table();
table.Width=new Unit("100%");

 table.Width = new Unit("70px");

Unit属于System.Web.UI.WebControls

的位置

答案 1 :(得分:0)

table.Width =新单位(“25%”)

适合我。