2016-01-25 83 views
0
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它不工作如何设置表格的宽度?

+1

我没有看到你尝试设置'table.witdh'的代码。如果你尝试了会发生什么? –

+0

当我试图table.width它显示相同的结果。这段代码的结果超出屏幕的水平 – Rabie

+0

所以添加代码,你分配一个'Width'表,并在那里你将它添加到页面的表。展会还与在其中添加表编程(如果它不是网页本身),包括所有相关的样式表的容器控制的ASPX。如果您要显示屏幕截图以及呈现的是什么html,这也有助于理解问题。 –

回答

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

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

Unit属于System.Web.UI.WebControls

+0

其不工作 – Rabie

+0

给'table.BorderWidth = 1; '看表的边缘,也检查容器宽度 –

+0

表的边缘超出屏幕 – Rabie

0

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

适用于我。