By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,668 Members | 1,606 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,668 IT Pros & Developers. It's quick & easy.

Persisting dynamic objects in Web Apps

P: n/a
Here's another goofy thing.

I need to persist the state of items added dynamically to a Panel control
between round-trips to the server.

I have a web form that contains a TreeView and a DropDownList

My web form reads the value of the drop down list, runs a query against a
database, then presents the results of the query to the user with a TreeView (IE
WebControls version). When the user checks an item's checkbox, the item is
deleted from the database on the next Postback.

However, I want to be able to place a series of objects (probably a HtmlTable)
to represent each object retrieved from the database into a Panel container.
(This will simulate the Large Icon view of an explorer window). Each object
would have some text, and a linkButton which when clicked will trigger the
database delete operation.

With the tree view, this is straightforward, since the treeview maintains its
nodes in the ViewState. The "Checked" handler takes care of this on the

But, if I use the series of HTML tables in the panel, every time the page loads,
the panel is emptied and nothing happens in the postback. If, during the
postback, I requery the database, and re-populate the panel, the LinkButton
handler is invoked and the record is deleted from the database as expected.

However, I don't want to have to requery the database on every postback.

Does anyone have a strategy for allowing the panel to keep track of the
HtmlTable elements it holds? Ive tried enabling it's viewstate, the viewstate of
the HtmlTable, and the LinkButtons, all to no avail. In the Page_Load (Postback
version), the Panel is always empty.

The closest I've come up with, is to build a DataTable with the information and
stash the DataTable into the ViewState or Session. Then on PostBack, get the
dataTable, and rebuild the HtmlTable elements, and re-populate the Panel

How do I persist my dynamically created HtmlTable controls?

All help is appreciated!


Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.