问题
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