Controls added to Tablecell loses data on postback.
Posted on 2007-10-18
I have a Table on my webpage.
On first load of the page i fill this table with new rows .
Each row has 2 cells.
Cell1 and Cell2.
For each cell i fill some stuff in.
for Cell1 i set .Text = "xxx".
for Cell2 i add a CheckBox as a new control to the cell.
The .Checked property of this CheckBox i set to a value from my SQL Statement.
All of this is working fine.
I add the properties to the cells after i add the cell to the row. This way i should save the text values ect. on postback.
And this works fine.
But, heres the problem.
For each Checkbox i've added to a cell, the user should be able to check this checkbox, and when i click a "Update SQL Table Button" on the webpage, i want to update my SQL Table and for each row in the table set the .Checked value in the SQL DB to match what the user choose on the website.
I do this by first calling a method called "CreateTableStructure()". This Method recreates all rows and cells and add's new checkboxes, but does not set the properties. This works fine...
After that i call a method called "UpdateSQLTaskList()". Both on page_Load event if the page is a postback.
but When i try to loop through my table all my checkbox values are = false, even though the are checked the the CreateTableStructure() has finished. I can see on the webpage that they are checked, but still the have a value of false, when trying to update my SQL DB.
What am i doing wrong?
Thank you in advance.