TreeView TreeNode SelectedNode Index ValuePath Indexing, Selecting, Server Side

Discussion in 'ASP .Net' started by Jared, May 29, 2006.

  1. Jared

    Jared Guest

    I am using a TreeView with data stored in a database and have been
    trying to store a node index over a postback and re-select the node
    without using javascript.

    I couldn't find anything in these groups to answer my question, so I
    thought somebody might find this method useful.

    You can use the TreeNode.ValuePath to select a node using the
    TreeView.FindNode() method.

    Firstly store the value path;

    Session["strNode"] = MyTreeView.SelectedNode.ValuePath;
    //I am storing in a session variable here.

    Then you can deselect your node if you want and carry on with other
    tasks, but you can still re-select by running the following.

    if (Convert.ToString(Session["strNode"]) != "")
    {
    TreeNode strNode =
    MyTreeView.FindNode(Convert.ToString(Session["strNode"]));
    strNode.Select();
    Session["strNode"] = "";
    }

    Hope this is useful.

    Jared
     
    Jared, May 29, 2006
    #1
    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. =?Utf-8?B?anlvdGkgcmFuamFu?=

    treeview selectednode

    =?Utf-8?B?anlvdGkgcmFuamFu?=, May 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,455
    avnrao
    May 6, 2004
  2. mike uk
    Replies:
    2
    Views:
    3,539
    mike uk
    Nov 19, 2005
  3. tanya foster
    Replies:
    3
    Views:
    3,785
    tanya foster
    May 18, 2006
  4. alexandis

    Find treenode by DataPath, not ValuePath

    alexandis, Feb 1, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    511
    alexandis
    Feb 1, 2008
  5. pardesiya

    How to determine TreeView SelectedNode relative position

    pardesiya, May 11, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    245
    pardesiya
    May 11, 2007
Loading...

Share This Page