Im working with a asp.net control (.ascx).
I add rows dynamically to a table like this with jQuery.
$('#<%= doorFileNameTable.ClientID %>').after('<tr><td></td><tr/>').append('<tr><td>' + fileName + '</td><tr/>')
<asp:Table runat="server" ID="doorFileNameTable">
<asp:TableRow><asp:TableCell></asp:TableCell></asp:TableRow>
</asp:Table>
But i cant see the dynamically added rows in the codebehind when i try like this, its always empty:
Table doorNamesTable = doorFileNameTable;
and i need to submit them to a database. Any ideas?
Dynamically added content will never survive a postback to the server, because the server didn’t initially render it and it’s not retained through the viewstate of the control. However, any data posted back with an ID within the form can be accessed through the Request.Form collection, or you can use a hidden field to store any dynamically generated content; the hidden field posts to the server, the server can respond to the content.
Dynamic content needs to be managed on every postback though; that’s the challenge with dynamic content and the server.
HTH.