Placeholder containing dynamic table is empty unless I create table twice

Posted by Mike O. on Stack Overflow See other posts from Stack Overflow or by Mike O.
Published on 2010-06-04T22:47:03Z Indexed on 2010/06/06 9:02 UTC
Read the original article Hit count: 205

Filed under:
|
|
|
|

I am dynamically creating a table that contains a textbox in each cell. The table is put in a placeholder control. Everything displays perfectly. The problem is when I go to retrieve the values entered in the cells. I have the code to generate the table in a separate method called CreateTable(). In order for my program to find a table in the placeholder when I go to save, I have to run CreateTable() in a postback event AND in the PageLoad event. If I call CreateTable() in only one of those places and I try to save, it says the placeholder is empty and, therefore, I cannot save the textbox contents. I've tried calling CreateTable() from InitLoad but that doesn't work because it needs to reference values from three static controls: 1 dropdown, 1 listbox, and 1 calendar control, which I don't believe have had their viewstate rendered yet. Anyone have any ideas? It would sure be nice not to have to double the number of database calls just to make this work.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET