Welcome Guest Search | Active Topics | Sign In | Register

TreeView.SelectedNode is null Options
XiA
Posted: Friday, June 24, 2011 4:19:07 PM
Rank: Newbie
Groups: Member

Joined: 6/23/2011
Posts: 7
I am using a TreeView in a regular ASP.NET page.
In my page I have a button that its on click event is handled from my server side code from behind code which looks like this:

protected void OnButtonAddNewFolderClick(object sender, EventArgs e)
{


var selectedTreeViewNode = _treeView.SelectedNode;
}

My problem is that if I select a node in the TreeView (which at this time has only one item) and then press the button although my code from behind is called, the value of _treeView.SelectedNode is null...

Any ideas of what I might be doing wrong here?
eo_support
Posted: Friday, June 24, 2011 4:24:50 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Please check whether you are recreating (rebinding) the TreeView on every request. The most common mistake to cause this problem is you did not put your data binding code inside "If (!Page.IsPostBack)" branch. That will cause the TreeView to be completely recreated every time even on post back and wipe our SelectedNode.

Thanks
XiA
Posted: Friday, June 24, 2011 4:57:36 PM
Rank: Newbie
Groups: Member

Joined: 6/23/2011
Posts: 7
Thanks... IsPostBack was my problem


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.