Solved

Value of type 'System.Web.UI.Control' cannot be converted to 'System.Web.UI.WebControls.TreeNode' !!

Posted on 2008-06-11
2
549 Views
Last Modified: 2008-06-15
Hi,

I have the following:

Request("Id") => Which represents the ID of the TreeNode.

I want to get the TreeNode from this. I have used the following syntax but never works for me:

Dim node As TreeNode = CType(FindControl(Request("Id")), TreeNode)

Error:

Value of type 'System.Web.UI.Control' cannot be converted to 'System.Web.UI.WebControls.TreeNode'

Can you please give me the correct syntax ?

Thanks
0
Comment
Question by:milani_lucie
2 Comments
 
LVL 11

Expert Comment

by:fanopoe
ID: 21763589
is sender one of the inputs to your procedure?
that gives you a reference that will either be direct or that you should be able to drill through to what you need.
0
 
LVL 16

Accepted Solution

by:
ororiole earned 500 total points
ID: 21763842
TreeNode unlike other controls does not inherit from System.Web.UI.Control. It inherits direct from System.Object only. So you can't find it using FindControl. It also does not have an ID property. You will have to go into the TreeView collection and search for it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now