RadTreeView inside User Control

1 posts, 0 answers
  1. Robert
    Robert avatar
    34 posts
    Member since:
    May 2009

    Posted 31 Jul 2009 Link to this post

    I have 2 RadTreeView inside a user control.  I am also using master pages.  When I run the web page the includes the user control.  The RadTreeViews inside the controls can not be found.  Below is my code.  Any help would be greatly appreciated.

            private void ParentDataSource(DataSet data, string nodeTextField, string nodeValueField, bool allowAddNew)
            {            
                **************** Object reference not set to an instance of an object. *************************************************
                rtvHierarchy.Nodes[0].AllowDrop = false;     *********************** I get the error here **********
            }




    <%

    @ Control Language="C#" AutoEventWireup="true" CodeBehind="Hierarchy.ascx.cs" Inherits="KMSF.Library.Telerik.Custom.Hierarchy" %>

     


     

        <telerik:RadAjaxPanel ID="rpnlPanel" runat="server" Width="100%">   
       
        <table border="1">
            <tr>
                <td>
                    <telerik:RadTreeView ID="rtvHierarchy" runat="server" OnNodeExpand="rtvHierarchy_NodeExpand"
                        OnContextMenuItemClick="rtvHierarchy_ContextMenuItemClick"
                        OnNodeEdit="rtvHierarchy_NodeEdit" OnNodeDrop="rtvHierarchy_NodeDrop" 
                        Height="500px" Skin="WebBlue">
                        <ContextMenus>
                            <telerik:RadTreeViewContextMenu ID="ContextMenu1" runat="server">
                                <Items>
                                    <telerik:RadMenuItem Value="Create" Text="Add New">
                                    </telerik:RadMenuItem>
                                </Items>
                            </telerik:RadTreeViewContextMenu>
                        </ContextMenus>
                        <Nodes>
                            <telerik:RadTreeNode runat="server" ContextMenuID="ContextMenu1" Text="Root" Expanded="true">
                            </telerik:RadTreeNode>
                        </Nodes>
                    </telerik:RadTreeView>
                </td>
                <td>
                    <telerik:RadTreeView ID="rtvAvailable" runat="server" EnableDragAndDrop="true"
                        OnContextMenuItemClick="rtvAvailable_ContextMenuItemClick"
                        OnNodeEdit="rtvAvailable_NodeEdit" OnNodeDrop="rtvAvailable_NodeDrop"
                        Height="500px" BorderStyle="None" Skin="WebBlue">
                        <ContextMenus>
                            <telerik:RadTreeViewContextMenu ID="ContextMenu2" runat="server">
                                <Items>
                                    <telerik:RadMenuItem Value="Create" Text="Add New">
                                    </telerik:RadMenuItem>
                                </Items>
                            </telerik:RadTreeViewContextMenu>
                        </ContextMenus>
                        <Nodes>
                            <telerik:RadTreeNode runat="server" ContextMenuID="ContextMenu2" Text="Root" Expanded="true">
                            </telerik:RadTreeNode>
                        </Nodes>
                    </telerik:RadTreeView>
                </td>
            </tr>
        </table>
       
        </telerik:RadAjaxPanel>



     

    <%@ Page Language="C#" MasterPageFile="~/WorkQueue.Master" AutoEventWireup="true"
    CodeBehind="ManageDeptDivHierarchy.aspx.cs" Inherits="KMSF.WorkQueue.UI.Web.MasterFiles.ManageDeptDivHierarchy" Title="Department Division Hierarchy Management" %>

    <%@ MasterType VirtualPath="~/WorkQueue.Master" %>
    <%@ Register Assembly="KMSF.Library.Telerik.Custom" Namespace="KMSF.Library.Telerik.Custom" TagPrefix="cc1" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

        <telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Hierarchy1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Hierarchy1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnSave">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Hierarchy1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>
        <table>
            <tr>
                <td>
                <asp:Button ID="btnSave" runat="server" Text="Save Changes" onclick="btnSave_Click"/><br />
                <cc1:Hierarchy ID="Hierarchy1" runat="server" ParentTreeViewTitle="Departments"
            ChildTreeViewTitle="Divisions" Height="200px" Width="150px" />
                </td>
            </tr>
        </table>
       
    </asp:Content>

Back to Top