Ticket Q213140
Visible to All Users

I need to find the parent node from within an ITemplate's InstantiateIn() sub.

created 16 years ago

I need to get the text from a node's parent node from inside the InstantiateIn() sub, but I just can't seem to figure it out. Thanks in advance for your help.

Show previous comments (1)
CS CS
Christina Sandefur 16 years ago

    Thanks for the quick reply Kate, but I'm having a lot of trouble casting the UI.Control to a TreeListNode. Here's what I'm doing:
    Private Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn
       …
       Dim n As TreeListNode = TryCast(container.NamingContainer, TreeListNode)
       …
    End Sub
    I get the following error:
    Value of type 'System.Web.UI.Control' cannot be converted to 'DevExpress.Web.ASPxTreeList.TreeListNode'.
    Thanks again!

    DevExpress Support Team 16 years ago

      Hi Christina:
      In this situation my previous solution is inapplicable, please accept my apologies for this inconvenience.
      Another solution is to find a corresponding node using the NodeKey.
      Here is a sample that illustrates this approach:

      Visual Basic
      Private Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn Dim con As TreeListDataCellTemplateContainer = TryCast(container, TreeListDataCellTemplateContainer) Dim tList As ASPxTreeList = con.TreeList Dim key As Object = con.NodeKey Dim node As TreeListNode = tList.FindNodeByKeyValue(key) End Sub

      Thanks
      Kate.

      CS CS
      Christina Sandefur 16 years ago

        Thanks for all your help Kate! That worked like a charm.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.