通过允许用户输入所需的no行,我已将控件动态添加到ASP .NET中的表中。addRow()函数的示例代码是:
HtmlTableCell cell_1 = new HtmlTableCell();
HtmlTableCell cell_2 = new HtmlTableCell();
l = new Label();
nomenclature = new TextBox();
unit = new TextBox();
row[i] = new HtmlTableRow();
label.Text = "" +(i+ 1);
cell_1.Controls.Add(l);
row[i].Controls.Add(cell_1);
nomenclature.TextMode = TextBoxMode.MultiLine;
nomenclature.Rows = 5;
nomenclature.Columns = 40;
nomenclature.ID="nomenclature"+i;
nomenclature.Text = "NA";
cell_2.Controls.Add(nomenclature);
row[i].Controls.Add(cell_2);
table_items.Controls.Add(row[i]);现在,在成功添加行之后,当我刷新页面并再次尝试添加新行时,它会给出sameID 'nomenclature0‘错误。
在这个问题上请帮帮我,
提前谢谢,
发布于 2014-06-23 12:07:29
关于你的密码我没有足够的信息。
有两种可能的解决办法:
1)在调用table_items.Controls.Clear函数之前尝试这个“addRows ();”。
2)如果是回发,不要填写表格。
https://stackoverflow.com/questions/24363184
复制相似问题