将一个list的数据源绑定到table中,再在div中显示出来
//绑定table
public void bindTAB(List<SurveyQuestion> lis)
{
//创建表格
Table tb = new Table() { ID = "tabsq" };
foreach (SurveyQuestion item in lis)
{
//创建行
TableRow tr = new TableRow();
tr.ID = item.id.ToString();
//创建单元格
TableCell tc = new TableCell();
tc.ID = item.id + item.parid.ToString();
tc.Text = item.title;
TableCell tcup = new TableCell();
tcup.Controls.Add(new Button() { Text = "修改" });
tcup.Controls.Add(new Button() { Text = "删除" });
//把单元格添加到行中
tr.Cells.Add(tc);
tr.Cells.Add(tcup);
//把行添加到表格
tb.Rows.Add(tr);
}
//把表格添加到层中
tabIn.Controls.Add(tb); ;
}