views:

239

answers:

2

I am using a treeview control inside an update panel. The checkednodes collection reset almost every time. Can you help?

A: 

I'm going to throw an answer out from left field as there's not a lot to work with here. Let's assume you are populating the Treeview on Page_Load or Page_PreRender. On postback, are you always rebinding the original dataset to the Treeview? Only bind if !IsPostBack and you should be all set.

Ben Griswold
I rebind only in case there has been some changes to the underlying data and inside !IsPostBack.Also, at times (after a postback due to node being expanded or otherwise too) the nodeclick event refreshes the whole page.But the issue of lost checkednodes is the most serious. The checkednodes works at the time of nodepopulate event in the postback. But the event page_preload or page_load that follows the treepopulate event shows ZERO count. I currently set the checkednodes to session and get it whenever required. But it needs lots of management.see more abot the issue at www.geekays.net
Kangkan
A: 

Eh! Its late, but I thought of updating this post now. I was working on the issue. The problem was that I was compelled to use the treeview under AJAX UpdatePanel. So, if I select a list of nodes in the treeview (my treeview is checkbox enabled), at times I find no checkboxes selected in the code-behind. So I did some study in the behaviours, read different posts in different forums and did some code to handle almost majority of the issues.

Anybody interested in the details may look at my post here: http://www.geekays.net/post/Using-TreeView-inside-AJAX-UpdatePanel.aspx

Kangkan