TreeView in ItemTemplate is blank after binding...

3 posts, 0 answers
  1. Peter From LA
    Peter From LA avatar
    36 posts
    Member since:
    May 2005

    Posted 16 Aug 2011 Link to this post

    I used the Combobox/Template example to build a RadComboBox with a RadTreeView as an ItemTemplate, but instead of a SqlDataSource I bound the tree in C# using a List<object>. The same tree works fine when it is by itself and shows all the data correctly, but when it is inside of the Item it is BLANK - the drop down is empty.

    this is my front end code:
    <telerik:RadComboBox
        ID="rcbDrawing"
        Width="205px"
        Height="300px"
        AllowCustomText="true"
        EmptyMessage="Select A Drawing"
        runat="server"
        Skin="Outlook"
        >
        <ItemTemplate>
            <div onclick="StopPropagation(event)">
                <telerik:RadTreeView
                    ID="treeDrawings"
                    runat="server"
                    DataTextField="Name"
                    DataValueField="ID"
                    DataFieldID="ID"
                    DataFieldParentID="ParentID"
                    Skin="Outlook"
                    OnClientNodeClicking="OnTreeNodeClicking"
                    ></telerik:RadTreeView>
            </div>
        </ItemTemplate>
        <Items>
            <telerik:RadComboBoxItem />
        </Items>
    </telerik:RadComboBox>


    This is how I do the binding:
    RadTreeView treeDrawings = (RadTreeView)rcbDrawing.Items[0].FindControl("treeDrawings");
    DrawingsCollection d = DrawingsCollection.GetByClientID(PageUser);
    treeDrawings.DataSource = d;
    treeDrawings.DataBind();
    treeDrawings.ExpandAllNodes();

    Am I doing anything wrong?
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 18 Aug 2011 Link to this post

    Hi Peter,

    Please take a look at the help article below. There you will find examples of how to bind the RadTreeView to an Array.
    • http://www.telerik.com/help/aspnet-ajax/treeview-data-binding-array.html

    Also make sure you have set the properties DataFieldID  and  DataFieldParentID  of the RadTreeView correct as noted in the help article.

    All the best,
    Ivana Gjorgeva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    651 posts

    Posted 20 Feb 2013 Link to this post

    Hello, Peter.

    With this release: 2013 Q1, we are releasing the DropDownTree -- a control designed to work in a manner similar to TreeView in ComboBox.

    Since you have such scenario, you might be interested. You can check the examples here -- http://demos.telerik.com/aspnet-ajax-beta/DropDownTree/Examples/Overview/Defaultcs.aspx -- or later on at the official (non-beta) site.

    Regards,
    Ivan Zhekov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top