|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Re: How to get underlying data of TreeView control? (ASP.NET 2.0)For your first problem. I don't believe the treeview supports 2 way
databinding - its only one way from data source control or object to the treeview but not back. Besides you either associate your treeview to a data source control (like XMLDataSource) using the DataSourceID property or a data object (like DataSet) using the DataSource property but not both. You'll need to work with the treeview directly on the postback but I might be wrong. For your second problem. There is no node id property within treenode, unless of course you subclass treenode and provide an id. What I do is use the name or value property of treenode to locate the node within the tree. Of course that assumes that the text and value are unique to each node. Eg. find the node by text. Public Function GetNodeByText(ByVal text As String) As MyTreeNode Return GetNodeByText(text, Nodes) End Function Public Function GetNodeByText(ByVal text As String, ByVal childNodes As TreeNodeCollection) As MyTreeNode Dim node As MyTreeNode For Each node In childNodes 'Search immediate children first If node.Text = text Then 'Found node with matching text. Exit For End If 'If children themselves have children then search those as well If node.ChildNodes.Count > 0 Then Return GetNodeByText(text, node.ChildNodes) End If Next Return node End Function Hope that helps. HI Caffiene.
Thanks for the answer. Unfortunately Text value of some of my nodes could be the same. However, they could be distinguished by some attribute value: every node has QUSTION_ID attribute, which is unique. On the other side I do not display value of that attribute. Is there some way to compare nodes based on this attribute? Best regards, placek I can't see a problem with finding nodes by the QUESTION_ID attribute.
Public Function GetNodeByQID(ByVal QID As String) As MyTreeNode Return GetNodeByQID(QID, Nodes) End Function Public Function GetNodeByQID(ByVal QID As String, ByVal childNodes As TreeNodeCollection) As MyTreeNode Dim node As MyTreeNode For Each node In childNodes 'Search immediate children first If node.Attributes("QUESTION_ID") = QID Then 'Found node with matching text. Exit For End If 'If children themselves have children then search those as well If node.ChildNodes.Count > 0 Then Return GetNodeByQID(QID, node.ChildNodes) End If Next Return node End Function Regards.
Adding controls to Pager row in GridView
Templated control not rendering Web User Controls ASP.NET 2.0 equivalent for e.Item.ItemIndex ? using placeholders Treeview control determining if node expanded or selected stylesheet on ASP.NET 2.0 TreeView and Menu Control want to create custom control using graphics Change style of Edit-button in GridView? servercontrols (webcontrols, htmlcontrols) or html elements? Gridview and colspan |
|||||||||||||||||||||||