Welcome Guest Search | Active Topics | Sign In | Register

Treeview - Dinamically generated HTML Options
Luis Angel
Posted: Thursday, March 13, 2008 10:25:10 AM
Rank: Member
Groups: Member

Joined: 2/25/2008
Posts: 14
Hi,

I'm populating a TreeView with nodes from my DB. Those nodes need to be modified by the user selecting an option from a dropdown related to each node, so I decided (based on another post) to generate manually the HTML code for each node. So I generate them with some code like this one:

Code: C#
EO.Web.TreeNode node = new EO.Web.TreeNode();
node.Text = "<SELECT name=........>" + "The Node Name";
...

treeview.Nodes.Add(node);
.
... add more nodes...
.
treeview.ExpandAll();


Then, on postback, I get the selected values accesing the Request.Form collection.

This code works perfectly... BUT only if I, either use the ExpandAll method, or expand manually all the nodes on the client. I've found that if the nodes are never expanded they don't "render" the expected HTML, so the generated SELECTS are not created in the browser and I get a NULL when I try to get the POSTed data...

So, my question is: is there a way to make the treeview to render/generate all the nodes even if they are collapsed?

Thanks in advance,
Luis


eo_support
Posted: Thursday, March 13, 2008 10:39:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,098
Hi Luis,

That's an interesting question. :) The TreeView is optimized to only initialize what's visible. In another word, anything that is not visible is not initialized. This greatly reduces the load time. But obviously this causes the problem you are seeing.

We could provide a way for you to render/generates all the nodes, but that will be at the cost of degrading performance, so we would rather not to do that. The easiest workaround for this situation is to store the initial value in ViewState, and when you get your form data, if you get a NULL, which means the node has never been displayed (thus never changed), you go back to your ViewState to get the initial value you stored in.

Thanks
Luis Angel
Posted: Thursday, March 13, 2008 3:45:15 PM
Rank: Member
Groups: Member

Joined: 2/25/2008
Posts: 14

Yes, I think you're right. I'll use Viewstate to store default values.

Thanks for the tip, and for this quick reply 8·)


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.