【发布时间】:2018-11-21 13:14:01
【问题描述】:
单击按钮后,我将表格行(包含 5 个表格单元格)添加到表格中。下面的代码工作正常,但我正在努力使这些表格单元格成为文本字段。因此,我应该以某种方式将以下内容放入表格单元格中:
<input type="text" id="rol_totaal" runat="server" class="tbl_input"/>
有什么想法可以在以下函数中实现吗?我在 ASP.NET 中使用 C#。
public void BtnAddCost_Click(object sender, EventArgs e)
{
var row = new HtmlTableRow() { };
var cell1 = new HtmlTableCell() { Height = "25px", InnerText="extra cost" };
cell1.Attributes.Add("class", "title_kost_tbl tbl_border_bottom");
var cell2 = new HtmlTableCell() { InnerText = "test 2" };
cell1.Attributes.Add("class", "grey_bg");
var cell3 = new HtmlTableCell() { InnerText = "test 3" };
cell1.Attributes.Add("class", "grey_bg");
var cell4 = new HtmlTableCell() { InnerText = "test 4" };
cell1.Attributes.Add("class", "grey_bg");
var cell5 = new HtmlTableCell() { InnerText = "test 5" };
cell1.Attributes.Add("class", "grey_bg");
row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
row.Cells.Add(cell4);
row.Cells.Add(cell5);
cost_tbl.Rows.Add(row);
}
【问题讨论】:
标签: c# asp.net html-table textfield