本文介绍了如何在ASP.NET中页面回发后保持treenode扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从DB绑定的树视图,假设我选择第二个节点并在其上创建一些操作,之后我正在进行页面回发并且我选择的节点自动折叠,我需要在页面回发后保持选定的节点扩展。



请帮帮我。



我尝试了什么:



我试过: -

protected void TreeView1_SelectedNodeChanged(object sender,EventArgs e)

{

ViewState [NodeValue] = TreeView1.SelectedNode.Value;

}



和按钮点击事件

protected void btnUploadFile_Click(object sender,EventArgs e)

{

TreeView1.SelectedNode.Value = ViewState [NodeValue]。ToString();

TreeView1.SelectedNode.PopulateOnDemand = true;

TreeView1.SelectedNode.Expanded = true;

}



这里我试图使用viewstate获取选定的节点值但仍无法正常工作..

i have a treeview which is binded from DB, suppose i select second node and create some operation on it, after that i am doing page postback and my selected node automatically get collapsed, i need to keep selected node expanded after page postback.

Please help me.

What I have tried:

I tried :-
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
ViewState["NodeValue"] = TreeView1.SelectedNode.Value;
}

And on button click event
protected void btnUploadFile_Click(object sender, EventArgs e)
{
TreeView1.SelectedNode.Value=ViewState["NodeValue"].ToString();
TreeView1.SelectedNode.PopulateOnDemand = true;
TreeView1.SelectedNode.Expanded = true;
}

here i tried to get selected node value using viewstate but still not working..

推荐答案

TreeListViewState.TreeListViewState _TreeListViewState = new TreeListViewState.TreeListViewState(ProductGroupTreeList);

_TreeListViewState.SaveState();

ProductGroupTreeList.DataSource = ...

_TreeListViewState.LoadState();





希望它有效。

最好的问候



hope it works.
best regards


这篇关于如何在ASP.NET中页面回发后保持treenode扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 01:25