Click to See Complete Forum and Search --> : Dynamic table vs viewState: i'm going crazy !!


bxlbjorn
09-13-2007, 10:34 AM
Dear developers,

I'm creating quite a sofesticated page (online timesheet) with most of the content being created dynamically.
A large portion consists of a table with many cells, each of them containing textboxes with several properties, such as text, visible, etc etc.
The data in the textboxes are retrieved based on a selected value from a dropdownlist ouside the table.

Here is the problem:
When I change my dropdownlist selection, a postback is triggered, different data is retrieved and all controls, cells and rows within the table are recreated. However the result in the page is the same: the same text remains, the properties are the same, even if in my code everything seems to work fine.
I have a slight idea that this might have to do with the viewstate, but i have absolutely NO idea where to start beating this problem.

Some aditional info:
The table control is already in the page.
Only the rows, cells and controls within the page are created dynamically and added.
I have been carefull about adding all objects in the right order aswell, eg first the textbox in the cell, then the cell in the row and finally the row in the table.

Can someone PLEASE help me with this cuz I'm going completely bonkers...

Many thanks,

Björn

lmf232s
09-13-2007, 02:59 PM
bxlbjorn,

Hey when are you creating the controls? Unless you create them in the Page_Init sub then your controls dont have viewstate.

Also can you post the code some code. What im looking for is your:
Page_Init
Page_Load
And either the code from your button click after you change the drop down or if you using the auto post back of the dropdown control then post that subs code.

* If you loading any kind of initial data in your Page_Load sub then you need to wrap this around it so it only loads the first time the page loads and not on postbacks.

Page_Load()....
If Not Page.IsPostBack Then
'Page Load
Else
'Post Back
End If
End Sub