J
Johan Åhlén
Hi,
Using a treeview with viewstate enabled easily generates very big viewstates
(hundreds of Ks). Does anyone have any experience of running treeviews
without viewstate?
To keep track of selected/clicked nodes I have added eventhandlers:
onselectedindexchange="javascript: if (this.clickedNodeIndex != null)
__saveSelectionState(this.clickedNodeIndex)"
oncheck="javascript: if (this.clickedNodeIndex != null)
__saveNodesState(this)"
and in Page_Load I retrieve the state...
protected void Page_Load(object sender, System.EventArgs e)
{
// Retain selected index
if ( IsPostBack )
{
string nodes = Request.Form[ statefield ];
if ( nodes == null )
nodes = "";
TreeView1.SelectedNodeIndex = nodes;
ExpandNodes( nodes ); // Make sure that selected node is visible
}
However, I sometimes get an error:
"The node at index 0.0 is not currently displayed in the tree.
SelectedNodeIndex cannot be set to an
undisplayed node (all parents of a selected node must be expanded)."
I have debugged the function ExpandNodes, which expands all nodes above the
selected one, but
can't find any problems.
Anybody have experience of this?
Thanks for any help!
Johan
---
Johan Åhlén
Bostadstips Sverige AB
Email: (e-mail address removed) <-- remove NOSPAM to email me
Web: http://www.bostadstips.com
Tel +46 31 842500
Using a treeview with viewstate enabled easily generates very big viewstates
(hundreds of Ks). Does anyone have any experience of running treeviews
without viewstate?
To keep track of selected/clicked nodes I have added eventhandlers:
onselectedindexchange="javascript: if (this.clickedNodeIndex != null)
__saveSelectionState(this.clickedNodeIndex)"
oncheck="javascript: if (this.clickedNodeIndex != null)
__saveNodesState(this)"
and in Page_Load I retrieve the state...
protected void Page_Load(object sender, System.EventArgs e)
{
// Retain selected index
if ( IsPostBack )
{
string nodes = Request.Form[ statefield ];
if ( nodes == null )
nodes = "";
TreeView1.SelectedNodeIndex = nodes;
ExpandNodes( nodes ); // Make sure that selected node is visible
}
However, I sometimes get an error:
"The node at index 0.0 is not currently displayed in the tree.
SelectedNodeIndex cannot be set to an
undisplayed node (all parents of a selected node must be expanded)."
I have debugged the function ExpandNodes, which expands all nodes above the
selected one, but
can't find any problems.
Anybody have experience of this?
Thanks for any help!
Johan
---
Johan Åhlén
Bostadstips Sverige AB
Email: (e-mail address removed) <-- remove NOSPAM to email me
Web: http://www.bostadstips.com
Tel +46 31 842500