Hi,
That is normal. Container.DataItem is only valid when you are data binding the control. In your case, because you are data binding the TreeView, not the ContextMenu, so TreeView has Container.DataItem but the ContextMenu does not.
In order for you to create data driven ContextMenu, you need to:
1. Populate the data into the TreeView first. You are populating the TreeView, not ContextMenu. So whatever data you want to have, you must store it into the TreeView first. Usually you would store such data into each TreeNode's Value property. I see that you already store ID into TreeNode.Value. So if you wish to store additional data into Value, you will want to concatenate them together. For example, if you wish to store both ID and "ItemName" into Value, you will need to do something like this:
Code: SQL
SELECT ID + '|' + ItemName AS ItemData .....
Then instead of mapping ID to TreeNode.Value, you would map ItemData to TreeNode.Value;
2. Handle the TreeNode's ClientSideOnContextMenu and displays the context menu. Before you display the context menu, you would call the TreeView's client side interface to get the Value property, extract whatever data you stored there, and then call the context menu's client side interface to update the menu. You can find an example on how to do this at here:
http://demo.essentialobjects.com/Default.aspx?path=TreeView\_i1\_i93. Displays the updated context menu;
You may also want to go over this topic if you are not familiar with our client side JavaScript API yet:
http://doc.essentialobjects.com/library/1/clientapi_howto.aspxHope this helps.
Thanks!