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

Discussion in 'ASP .Net' started by tanya foster, May 16, 2006.

  1. tanya foster

    tanya foster Guest

    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.
     
    tanya foster, May 16, 2006
    #1
    1. Advertising

  2. tanya foster

    Alvin Bruney Guest

    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" <> wrote in message
    news:...
    > 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.
     
    Alvin Bruney, May 17, 2006
    #2
    1. Advertising

  3. tanya foster

    tanya foster Guest

    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.
     
    tanya foster, May 18, 2006
    #3
  4. tanya foster

    tanya foster Guest

    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.
     
    tanya foster, May 18, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Olurotimi Ige
    Replies:
    2
    Views:
    560
    Patrick Olurotimi Ige
    Feb 15, 2005
  2. gane kol
    Replies:
    1
    Views:
    362
    Scott Allen
    Apr 15, 2005
  3. Annie
    Replies:
    1
    Views:
    4,088
    Eliyahu Goldin
    Sep 27, 2005
  4. =?Utf-8?B?VGltX2s=?=

    Control class has no text property in webcontrols?

    =?Utf-8?B?VGltX2s=?=, Mar 14, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    426
    =?Utf-8?B?VGltX2s=?=
    Mar 14, 2006
  5. Charlie@CBFC
    Replies:
    0
    Views:
    744
    Charlie@CBFC
    Dec 14, 2006
Loading...

Share This Page