Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Table Ignores EnableViewState

Reply
Thread Tools

Table Ignores EnableViewState

 
 
Jonathan Wood
Guest
Posts: n/a
 
      01-27-2008
I have a table that I dynamically populate by creating cells and rows. The
data comes from a database so I would prefer to have the table store the
data in its viewstate rather than having to repopulate it on every postback.

But it doesn't work. I ensure the table's EnableViewState is true. But
whenever there's a postback and I don't repopulate the table, it disappears.
I'm thinking this has something to do with my dynamic data not being stored
in the table's viewstate. But I'm not sure why or what the best workaround
is.

Any tips?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

 
Reply With Quote
 
 
 
 
forever.zet@gmail.com
Guest
Posts: n/a
 
      01-27-2008
On 27 , 22:46, "Jonathan Wood" <(E-Mail Removed)> wrote:
> I have a table that I dynamically populate by creating cells and rows. The
> data comes from a database so I would prefer to have the table store the
> data in its viewstate rather than having to repopulate it on every postback.
>
> But it doesn't work. I ensure the table's EnableViewState is true. But
> whenever there's a postback and I don't repopulate the table, it disappears.
> I'm thinking this has something to do with my dynamic data not being stored
> in the table's viewstate. But I'm not sure why or what the best workaround
> is.
>
> Any tips?
>
> Thanks.
>
> --
> Jonathan Wood
> SoftCircuits Programminghttp://www.softcircuits.com


Hi Jonathan,

One option would be to create cells and rows in page's
CreateChildControls method (you might
store number of rows and cells in page's ViewState, so you can
recreate exactly the same number of rows/cells on postback),
So as soon as you create them in CreateChildControls they will be
recreated on postback and will grab all properties
you have assigned to them initially from ViewState.
You might also need to call EnsureChildControls before you assign/read
cell properties (in Page_Load or smth.).


Thanks,
Sergey Zyuzin
 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      01-28-2008
"Jonathan Wood" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

>I have a table that I dynamically populate by creating cells and rows. The
>data comes from a database so I would prefer to have the table store the
>data in its viewstate rather than having to repopulate it on every
>postback.
>
> But it doesn't work. I ensure the table's EnableViewState is true. But
> whenever there's a postback and I don't repopulate the table, it
> disappears. I'm thinking this has something to do with my dynamic data not
> being stored in the table's viewstate.


It's not your dynamic data as such - it's that dynamically added controls
(in this case, <tr> and <td>) don't survive a postback, and need to be
recreated every time the page loads...

> Any tips?


Use a GridView...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE ignores table cell height propery - why? Andrey Tarasevich HTML 6 08-09-2005 05:09 PM
EnableViewState not working on table AFN ASP .Net 6 01-17-2005 02:45 AM
enableviewstate=false, still viewstate information is added sultan zahir khan ASP .Net 2 07-24-2003 02:08 PM
enableviewstate=false, still viewstate information is added Ravikanth[MVP] ASP .Net 1 07-24-2003 12:58 PM
EnableViewState = false not working Dave Verwer ASP .Net 0 07-10-2003 10:31 AM



Advertisments