Loading New Nodes From Database

3 posts, 0 answers
  1. tbrown
    tbrown avatar
    4 posts
    Member since:
    May 2008

    Posted 25 Jun 2008 Link to this post

    Hi all,

    I have a tree view that is going to be used for an email application and has all of its folder structure bound from a self referencing database table. When I do my binding I set a node attribute of FolderId to each node on the NodeDataBound event (e.Node.Attributes.Add("FolderId", currentNode["FolderId"].ToString());) so that I can access the FolderId in the code behind.

    I have a context menu on the tree view that allows the user to add, rename and delete a folder. This is done on the ContextMenuItemClick event of the context menu and updates the database accordingly. Howerver what I am having problems with is updating the new folder with the new default text of ‘New Folder’ and applying the newly created FolderId from the database when a user clicks the create item in the context menu. The only way I found to do this is to reload the whole menu in again and bind. However this is a very poor solution and with the possability of hundereds of folders performance is likely to suffer and has the addeded annoyence of closing the menu back to the root rather than keeping it open on the selected node.

    Is there a way I can click the context menu and create the new folder by adding it to the database. Then updating the newly created folder with its FolderId from the database whilst keeping the menu expanded on the selected node?

    Any help with this would be much appreciated.

  2. Sergej
    Sergej avatar
    3 posts
    Member since:
    Apr 2008

    Posted 29 Sep 2009 Link to this post

    I have similar problem when adding new node from code behind. Problem is related to binding data to treeview, My node template looks like this:

    [<%# DataBinder.Eval(Container, "Value")%>] <%# DataBinder.Eval(Container, "Text")%>

    from codebehind node is added :

    RadTreeNode newNode = new RadTreeNode("MyNewNode", "2222");


    In tree new node looks like this: "[] ".  I know the node is added because if i edit (rename) the node from client side "[] " it will show MyNewNode text in textbox so I can edit the text.

    I have latest official release of rad controls.

    Support please tell us what to do.

  3. Yana
    Yana avatar
    5043 posts

    Posted 02 Oct 2009 Link to this post

    Hi Sergej,

    You should also call DataBind method of the node:

    RadTreeNode newNode = new RadTreeNode("MyNewNode""2222"); 

    Kind regards,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top