473,287 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

what is equivalent of vb.net treenode.nextnode property in asp.net webcontrols.treenode

Hello,
I am re-writing a visual basic .net application(visual studio 2003) in an
asp.net application(visual studio 2005). The vb.net application relied on a
treeview and hence, treenodes. The treeview and treenode class in asp.net
is limited compared to vb.net's. In vb.net, the treenode had a nextnode
property which was equivalent to finding the next sibling of the treenode.
asp.net's treenode has a child property and a parent property. Any ideas on
how to determine the sibling of a treenode in asp.net's treenode class? I
am looking for the nextnode of the treeview.selectednode.
thanks.
May 16 '06 #1
3 4007
There is no next pointer, you will need to find the current node and then
iterate its collection of child nodes. The effect is the same, different
perspective.

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------

"tanya foster" <ju*******@yahoo.com> wrote in message
news:31******************************@ureader.com. ..
Hello,
I am re-writing a visual basic .net application(visual studio 2003) in an
asp.net application(visual studio 2005). The vb.net application relied on
a
treeview and hence, treenodes. The treeview and treenode class in asp.net
is limited compared to vb.net's. In vb.net, the treenode had a nextnode
property which was equivalent to finding the next sibling of the treenode.
asp.net's treenode has a child property and a parent property. Any ideas
on
how to determine the sibling of a treenode in asp.net's treenode class? I
am looking for the nextnode of the treeview.selectednode.
thanks.

May 17 '06 #2
Alvin,
Sounds good but I am not visualizing it completely. Getting the
currentnode is easy as in treeview.selectednode. If I iterate through the
children of treeview.selectednode, then I am not getting a sibling of the
current node but i would be going after its children. There is a "child"
and a "parent" property available. I want the sibling or nextnode treenode.
Do you mean to get the parent of the currentnode and then iterate through
its children? I am sorry I don't quite understand but would love to.
May 18 '06 #3
Thanks Alvin for your help.

Here is my code which might help another asp.net developer or anyone else
when they are trying to get to the sibling treenodes or nextnodes in system.
web.ui.webcontrols.treeview or treenode classes.

Here is an example of the treeview structure used(I am displaying it as xml
though)

.....
<material>
<partnumber>12345</partnumber>
<description>5 feet long pipe</description>
<units>10</units>
<type>stocked</type>
</material>
<material>
<partnumber>8888</partnumber>
<description>machine saw and drill</description>
<units>2</units>
<type>on order</type>
</material>
....
When the user selects the partnumber to edit, after I validate that the new
partnumber exists in a table, I want to update the description treenode with
the matching description from the same table. I do not allow the user to
edit the description treenode.

The function below(written in .NET Framework version 2.0 asp.net) receives a
string and updates the description treenode of the partnumber the user
selected to edit.

TreeViewForXml is a system.web.ui.webcontrols.treeview

Assumption #1: TreeViewForXml.SelectedNode was a partnumber changed to a
valid new partnumber

Assumption #2: When the treeview was populated, the treenode.value field
was populated with the name of the xml element or xml attribute

Private Function UpdateDescriptionTreeNode(ByVal NewDescription As String)
As Boolean

Dim NodeOfInterest As TreeNode
Dim k As Integer
Dim FoundDescriptionTreeNode As Boolean

FoundDescriptionTreeNode = False
'get the parent node of the selected node
NodeOfInterest = TreeViewForXml.SelectedNode.Parent

'now parse through the children nodes to locate selectednode's sibling
that contains description

If Not (NodeOfInterest Is Nothing) And NodeOfInterest.ChildNodes.Count >
0 Then

For k = 0 To NodeOfInterest.ChildNodes.Count - 1
If NodeOfInterest.ChildNodes(k).Value = "description" Then
NodeOfInterest.ChildNodes(k).Text = NewDescription
FoundDescriptionTreeNode = True
End If
Next

End If

Return FoundDescriptionTreeNode

End Function

I do hope the asp.net team SOON implements the nextnode property just like
in the System.Windows.Forms.treenode class.

Thanks for your suggestions and clarifications Alvin.
May 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
6
by: Dean L. Howen | last post by:
Hi, I want to add some attributes to TreeNode, so I create a new class MyNode that inheritance from System.Windows.Forms.TreeNode, I want to TreeView use MyNode instead of TreeNode, so I can...
2
by: The Kiddie | last post by:
Hi Guys, I am doing some work with a treenode and I want to record the selected item, and it may change while the user is performing some tasks and I need to know which one was originally...
4
by: Mark Goldin | last post by:
Here is an ASP page: <%@ Register TagPrefix="mytree" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %> <%@ import namespace="Microsoft.Web.UI.WebControls"%>...
4
by: Turban | last post by:
When I attempt to run the following code: protected void NavigationTreeView_TreeNodePopulate(object sender, TreeNodeEventArgs e) { TreeNode tn1 = new TreeNode("node1","node1"); TreeNode tn2 =...
11
by: Alan T | last post by:
I am using VS 2005 and just wonder why I don't have this method?
0
by: John Faris | last post by:
Hi all. I have a class that inherits from TreeNode and adds a generic property, NodeObject. Then I have several other classes that inherit from this class and specify the type of NodeObject as...
5
by: celoftis | last post by:
Using VS2005 ASP.NET 2.0, VB code behind: I have a windows forms based application that I need to port to the web. One of the major components of my windows forms based application is a TreeView...
4
by: Karl Rhodes | last post by:
Hi all... Perhaps I'm not going about this the right way, but I wondered if anyone can help? I have a treeview which populates from a datatable using a parent/ child relationship. It stores a...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.