在回发中向HtmlTable添加行 [英] Adding rows to HtmlTable on Postback

查看:74
本文介绍了在回发中向HtmlTable添加行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个HtmlTable.我试图在用户通过单击按钮提交表单后在PostBack上添加行,只需声明单元格,将它们添加到新的HtmlTableRow myNewRow中,然后使用方法myTable.Rows.Add(myNewRow)

在PostBack之后,将添加新行,但是我之前添加的所有其他行都将丢失.我希望行累积起来.我该怎么办?

[Mark Nischalke:信息输入到TextBox中..我通过创建一个会话变量来存储List(Of HtmlTableRow)对象来解决我的问题-每次页面加载时,我都会遍历它来填充HtmlTable.现在唯一的问题是我必须确保会话不会过期,所以我正在努力.感谢您的帮助.]

谢谢

Hello,

I have an HtmlTable. I am trying to add rows on PostBack after the user submits the form by clicking a button, simply by declaring cells, adding them to a new HtmlTableRow myNewRow and then using the method myTable.Rows.Add(myNewRow)

After PostBack, the new row is added, however all other rows that I previously added are lost. I would like the rows to accumulate. How can I do this?

[Mark Nischalke: the information is entered in TextBox''s.. I fixed my problem by creating a session variable to store a List(Of HtmlTableRow) object - every time the page loads, I iterate through it to populate my HtmlTable. Now the only problem is I have to make sure the session does not expire, so I''m working on that. Thanks for your help.]

Thanks

推荐答案

您需要以某种方式保留行,以便可以重新创建它们.信息从何而来?使用数据绑定和gridview,Datalist或其他类型的控件会更好吗?
You need to to persist the rows somehow so they can be recreated. Where is the information coming from in the first place? Would it be better to use databinding and a gridview, Datalist, or other type of control?


这篇关于在回发中向HtmlTable添加行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆