Solved

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

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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