添加新控件后添加新行

时间:2016-07-14 17:11:03

标签: c# asp.net

添加每个控件后,如何添加新行?我添加的控件是表格单元格。

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);                
}

1 个答案:

答案 0 :(得分:0)

您可以通过LiteralControl类插入换行符作为HTML文字:

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