Post Backs and dynamically created tables

J

Jason

Hi all

I am building a page dynamically on Page_Load. using Table web controls for
this.
the web page builds up and loads up and displays ok. but as soon as there is
a post back of any sort, all my dynamic building is gone. the page reverts
back to it's "original" design time state.

i have a OK button, that when the user clicks on this button, it will go and
get data from the dynamically built page. but obviously i cant do that,
because the dynamically built page is now gone, due to the post back.

how do i get around this?

Thanks
Jason
 
J

Jeremy Ames

Is your table being loaded within an if block that tests for post back?

ex:
if(!IsPostBack)
LoadMyTable();

If this is the case, you should remove that code from the if block.
--

Thanks,

Jeremy Ames
Code Powered Technologies
 
J

Jason

but then the table and all it's contents will be recreated, therefore the
user input is lost. right?
 
J

Jeff Evans

Jason said:
but then the table and all it's contents will be recreated, therefore the
user input is lost. right?


For dynamic controls, if you create the controls with the same ID on each
page request, ASP.NET will repopulate their values with Postback data. Load
is a little bit late, technically, to do this, but it should still work as
the controls will play "catch-up".
 
D

darrel

but then the table and all it's contents will be recreated, therefore the
user input is lost. right?

No, that was checking for NOT postback. Ie, that will cause the table to be
built on page_load the first time the page is loaded, but not on postback.
It sounds like you are building the table on both the first page load and on
the postback right now.

-Darrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top