2016-07-14 104 views
0

如何在添加每個控件後添加新行?我添加的控件是一個表格單元格。添加新控件後添加新行

for (int i = 0; i < 60; i++) 
{ 
    CheckBox cb = new CheckBox(); 
    cb.ID = "MitchelF" + i.ToString(); 
    Label lbl = new Label(); 
    lbl.Text = "MitchelF"; 
    lbl.Font.Size = new FontUnit("18px"); 
    lbl.ID = "MitchelF" + i.ToString(); 
    cellUsersPool.Controls.Add(cb); 
    cellUsersPool.Controls.Add(lbl);     
} 
+0

對不起,謝謝! –

回答

0

你可以插入一個斷行作爲HTML通過LiteralControl類文字:

// Add your elements 
cellUsersPool.Controls.Add(cb); 
cellUsersPool.Controls.Add(lbl); 
// Explicitly insert a line break 
cellUsersPool.Controls.Add(new LiteralControl("<br />"));