Access <asp:table> table rows added by javascript in asp.net webform

孤街浪徒 提交于 2020-01-06 21:06:06

问题


have an app that is trying to capture several entries added to an control by the user. The user enteres data into a single text box and then clicks add. This value is then appended to the table like so: <tr><td>some value</td></tr>

I'm trying to avoid round trips so the server but so far am having trouble. The form posts back but the new added rows aren't in the .Rows collection... is this possible to do?


回答1:


You cannot get table rows added at client side appear into server side row collection because server side table control has no way to know such modifications.

The simplest thing that you can do is to maintain one (or more hidden) fields that stores the data of dynamically added rows. So when form posts back you can access the data from hidden field (if you use server side hidden field) or from Request.Form by looking up using name value of hidden field.



来源:https://stackoverflow.com/questions/6979049/access-asptable-table-rows-added-by-javascript-in-asp-net-webform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!