Server端的table,在动态增加行后原有属性丢失

Jouzen 2004-12-24 11:28:01
比如我一个Server端的Table定义如下
<table class="tabp" id="MainTbl" runat="server">
<tbody>
<tr><td>aaa</td></tr>
</tbody>
</table>
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cell = new HtmlTableCell();
cell.InnerHtml= " ";
row.Cells.Add(cell);
MainTbl.Rows.Add(row);
执行后原有的<tbody>属性丢失,有什么好的解决方法?
...全文
189 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jianli0108 2004-12-27
  • 打赏
  • 举报
回复
看了saucer(思归)的,学习了很多,谢谢楼主哦!
saucer 2004-12-27
  • 打赏
  • 举报
回复
你总可以自己写个Server Control,输入TABLE,添加这些玩意
goody9807 2004-12-27
  • 打赏
  • 举报
回复
Note A complex table model is not supported. You cannot have an HtmlTable control that nests <caption>, <col>, <colgroup>, <tbody>, <thead>, or <tfoot> elements. These elements are removed without warning and do not appear in the output HTML. An exception will be thrown if you attempt to programmatically add these table model elements to the Control.Controls collection of the HtmlTable control.

不支持添加<tbody>, <thead>, 这样的属性 如果用程序动态添加这样的属性那么会抛出一个异常
Jouzen 2004-12-26
  • 打赏
  • 举报
回复
谢谢 saucer(思归)
只是很奇怪,为什么要丢失,而保持原来的一些属性应该并不困难。
slhuang 2004-12-25
  • 打赏
  • 举报
回复
偶试了一下。不会啊。不知道所谓的丢失属性是什么?
Jouzen 2004-12-25
  • 打赏
  • 举报
回复
自己顶
lr2651 2004-12-25
  • 打赏
  • 举报
回复
外面只声明一个table <table id="table1" runat="server"/>
其余都到后台加
table1.InerrText += "你要加的所有东西"
saucer 2004-12-25
  • 打赏
  • 举报
回复
这是该控件在当前实现下的正常行为,参考文档

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuihtmlcontrolshtmltableclasstopic.asp


A complex table model is not supported. You cannot have an HtmlTable control that nests <caption>, <col>, <colgroup>, <tbody>, <thead>, or <tfoot> elements. These elements are removed without warning and do not appear in the output HTML. An exception will be thrown if you attempt to programmatically add these table model elements to the Control.Controls collection of the HtmlTable control.

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧