Welcome Guest Search | Active Topics | Sign In | Register

Casting Navigationitem to Menuitem Options
ITMA
Posted: Tuesday, August 17, 2010 6:33:26 PM
Rank: Advanced Member
Groups: Member

Joined: 6/23/2010
Posts: 48
Hi,

I am not successful when casting from a Navigationitem to a Menuitem when using a TreeView and itemclick. It's somewhat embarrassing and bothering as I’ve spent some time now. Just a small input from your support would help me a great deal finding my path again... d'oh!

As I'm programming in VB I should become extremely satisfied with an example that gives some input on how to do a proper cast. What I wish to accomplish in the end is to have the treenode id value and the dataFolder text from the treviewnode that I’ve clicked.

I’m using your treeview example and have been successful in having it databinding and saving to my SQL-server datasource.

Thanks for your help and highly competent controls! Angel




Best Regards
ITMA




eo_support
Posted: Tuesday, August 17, 2010 7:29:45 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I am not exactly sure why you need to cast a NavigationItem into a MenuItem a TreeView --- such conversion does not exist. NavigationItems in a TreeView are TreeNode, they are not MenuItem, so you can can only cast them into TreeNode, not into MenuItem.

Usually you do not need to do the casting at all. For example, if you are handling the TreeView's ItemClick event, you would simply use "e.TreeNode" to reference the clicked node. For example, the following code set Label1 to show the clicked node's text:

Code: Visual Basic.NET
Protected Sub TreeView1_ItemClick( _
    ByVal sender As Object, _
    ByVal e as EO.Web.NavigationItemEventArgs)
    Label1.Text = e.TreeNode.Text
End Sub


Note it uses "e.TreeNode" to get the TreeNode object directly.

Hope this helps.

Thanks!
ITMA
Posted: Monday, August 23, 2010 11:05:31 AM
Rank: Advanced Member
Groups: Member

Joined: 6/23/2010
Posts: 48
Hi,

I was successful, apreciate your superb support...

When working with the TreeView control this works fine. It is something that I not understand because when I'm using the menu control instead. Then I have following error.

The Code:

Protected Sub Menu2_ItemClick(ByVal sender As Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles Menu2.ItemClick

Session("FolderID") = e.TreeNode.Text


Results in error:

[NullReferenceException: Object reference not set to an instance of an object.]
a_TeamLean_01.Menu2_ItemClick(Object sender, NavigationItemEventArgs e) in C:\home\teamlean1\www\Default\TeamLean\a_Master\a_TeamLean.master.vb:96
EO.Web.BaseNavigator.a(NavigationItem A_0) +58
EO.Web.BaseNavigator.h(String A_0) +175
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563


Best regards,

ITMABrick wall
eo_support
Posted: Monday, August 23, 2010 4:33:58 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Just like you should not cast a NavigationItem into a MenuItem in a TreeView, you should not cast a NavigationItem into a TreeNode in a menu either. .NET is strong typed. Menu has menu items. TreeView has tree nodes. You should never mix them up.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.