while (reader.Read())
{
TableRow r = new TableRow();
TableCell c = new TableCell();
c.Controls.Add(new LiteralControl(reader["Name"].ToString()));
r.Cells.Add(c);
Table1.Rows.Add(r);
TableCell c1 = new TableCell();
c1.Controls.Add(new LiteralControl(reader["RollID"].ToString()));
r.Cells.Add(c1);
Table1.Rows.Add(r);
}
我想为每一行添加另一个带有下拉列表的单元格。是否有人可以解决这个问题?
答案 0 :(得分:6)
你可以这样做......
DropDownList ddl = new DropDownList();
ddl.ID = "ddl";
ddl.Items.Add(new ListItem("Text", "Value")); // add list items
TableCell c2 = new TableCell();
c2.Controls.Add(ddl);
r.Cells.Add(c2);
Table1.Rows.Add(r);