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?
|
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
|
Rank: Newbie Groups: Member
Joined: 6/23/2011 Posts: 7
|
Thanks... IsPostBack was my problem
|