2016-07-14 103 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 />"));