Work on Asp.net VS08.In my master page i need to fill a treeview form database.I do开发者_Python百科ne it,i set the NavigationUrl value.When user click a leaf ,then they see there wanted page.But then the MasterPage tree become expanded on root.I want the tree will not expanded and tree will the same as before click on leaf.
You're navigating to a new page: the treeview has lost its state. You need to manually set the SelectedValue to the one the user has selected (you probably have this as a querystring parameter in your new page). Furthermore, you need to manually set the expanded state of its parents.
If you don't want to lose its state, you'll need to do some postbacks to the same page instead of navigating to a new page and handle the OnSelectedNodeChanged event.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.onselectednodechanged.aspx
精彩评论