ASP.NET 2.0 TreeView - Programatically Selecting A TreeView Node

Discussion in 'ASP .Net' started by =?Utf-8?B?VHltYm93?=, Jan 8, 2006.

  1. I'm building a web application that is analogous to the Windows XP file
    explorer in function. The left column contains a TreeView, and the right
    column a DataGrid populated by selecting TreeView nodes. The TreeView
    populates dynamically as there are a significant number of nodes. The
    DataGrid displays both the items and the nodes from the TreeView. Using the
    explorer analogy this means the TreeView shows folders, and the DataGrid
    folders and files.

    The issue I have is that I would like to be able to update the TreeView to
    show the selected node if the user selects the matching node from the
    DataGrid. Again with the Explorer analogy, if the user selected a folder, the
    folder tree would update to match the change. I'm not sure it's possible due
    to the dynamic nature of the TreeView in this example as the node may not
    even exist in the nodes collection (eg: The TreeView shows the root node plus
    1 level but the user has drilled down 3 levels in the DataGrid from the root
    node).

    Any suggestions?

    Kind Regards,
    Tim.
     
    =?Utf-8?B?VHltYm93?=, Jan 8, 2006
    #1
    1. Advertising

  2. Hello Tim,

    Maybe you could try something like this
    Check if a folder item is selected in a datagrid item in the
    selectedindexchanged event. If so expand the folder Node in the treeview
    with findnode and expand
    Treeview1.FindNode("Authors\\Shakespeare").Expand(); or Select

    I hope this contributes to a solution.

    regards,

    Koen Hakvoort



    "Tymbow" <> wrote in message
    news:...
    > I'm building a web application that is analogous to the Windows XP file
    > explorer in function. The left column contains a TreeView, and the right
    > column a DataGrid populated by selecting TreeView nodes. The TreeView
    > populates dynamically as there are a significant number of nodes. The
    > DataGrid displays both the items and the nodes from the TreeView. Using
    > the
    > explorer analogy this means the TreeView shows folders, and the DataGrid
    > folders and files.
    >
    > The issue I have is that I would like to be able to update the TreeView to
    > show the selected node if the user selects the matching node from the
    > DataGrid. Again with the Explorer analogy, if the user selected a folder,
    > the
    > folder tree would update to match the change. I'm not sure it's possible
    > due
    > to the dynamic nature of the TreeView in this example as the node may not
    > even exist in the nodes collection (eg: The TreeView shows the root node
    > plus
    > 1 level but the user has drilled down 3 levels in the DataGrid from the
    > root
    > node).
    >
    > Any suggestions?
    >
    > Kind Regards,
    > Tim.
     
    Koen Hakvoort, Jan 8, 2006
    #2
    1. Advertising

  3. Re: ASP.NET 2.0 TreeView - Programatically Selecting A TreeView No

    That helped. Thanks.

    FYI it can be done but it gets a little ugly. Due to the dynamic nature of
    the treeview you must remember to use select() and expand() when you change
    nodes outside of the tree or things can get very lost. I didn't have much
    luck with find node and ended up just iterating the child nodes looking for a
    ValuePath match but I'll try to get FindNode working (I hate text matching -
    very ugly and requires too much support code to handle unexpected input).

    "Koen Hakvoort" wrote:

    > Hello Tim,
    >
    > Maybe you could try something like this
    > Check if a folder item is selected in a datagrid item in the
    > selectedindexchanged event. If so expand the folder Node in the treeview
    > with findnode and expand
    > Treeview1.FindNode("Authors\\Shakespeare").Expand(); or Select
    >
    > I hope this contributes to a solution.
    >
    > regards,
    >
    > Koen Hakvoort
    >
    >
    >
    > "Tymbow" <> wrote in message
    > news:...
    > > I'm building a web application that is analogous to the Windows XP file
    > > explorer in function. The left column contains a TreeView, and the right
    > > column a DataGrid populated by selecting TreeView nodes. The TreeView
    > > populates dynamically as there are a significant number of nodes. The
    > > DataGrid displays both the items and the nodes from the TreeView. Using
    > > the
    > > explorer analogy this means the TreeView shows folders, and the DataGrid
    > > folders and files.
    > >
    > > The issue I have is that I would like to be able to update the TreeView to
    > > show the selected node if the user selects the matching node from the
    > > DataGrid. Again with the Explorer analogy, if the user selected a folder,
    > > the
    > > folder tree would update to match the change. I'm not sure it's possible
    > > due
    > > to the dynamic nature of the TreeView in this example as the node may not
    > > even exist in the nodes collection (eg: The TreeView shows the root node
    > > plus
    > > 1 level but the user has drilled down 3 levels in the DataGrid from the
    > > root
    > > node).
    > >
    > > Any suggestions?
    > >
    > > Kind Regards,
    > > Tim.

    >
    >
    >
     
    =?Utf-8?B?VHltYm93?=, Jan 10, 2006
    #3
    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. Replies:
    0
    Views:
    1,462
  2. Tjerk Wolterink
    Replies:
    2
    Views:
    1,436
    Dimitre Novatchev
    Aug 24, 2006
  3. Liliana García

    Treeview- programatically select a Node

    Liliana García, Jul 17, 2003, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    252
    Alvin Bruney
    Jul 18, 2003
  4. Rod Early

    Treeview Web Control - selecting a node

    Rod Early, Dec 8, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    181
    Rod Early
    Dec 15, 2003
  5. dhurwitz

    Programmatically selecting a node in a TreeView

    dhurwitz, Jun 13, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    205
    dhurwitz
    Jun 13, 2006
Loading...

Share This Page