Solved

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

Posted on 2008-06-11
2
547 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

12 Experts available now in Live!

Get 1:1 Help Now