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.