[英]Inserting DropDownList in a TableCell
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);
}
我想為每一行添加另一個帶有下拉列表的單元格。有人可以解決這個問題嗎?
你可以這樣做...
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.