This is a migrated thread and some comments may be shown as answers.

CheckBoxList within NodeTemplate

3 Answers 11 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 28 Mar 2013, 08:55 PM

I'm trying to do something that I think shold be simple but it doesn't seem to be working.  I have the TreeView set with a datasource to build out one level of nodes.  Within each of those nodes I want a CheckBoxList which uses another datasource.  When I do this though the CheckBoxList doesn't show up at all.  Do I need to go about this another way?

<telerik:RadTreeView ID="rtvCapabilities" runat="server" CheckBoxes="false" DataSourceID="odsCapabilityList" DataTextField="Capability_ID" DataValueField="Capability_ID">
   <Nodes>
       <telerik:RadTreeNode>
           <NodeTemplate>
               <asp:CheckBoxList ID="cblExpertise" runat="server" RepeatColumns="3" RepeatDirection="Vertical" DataSourceID="odsWSExpertiseList" DataTextField="Description" DataValueField="ID" />
           </NodeTemplate>
       </telerik:RadTreeNode>
   </Nodes>
</telerik:RadTreeView>

3 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 29 Mar 2013, 08:32 AM
Hello Stephen,

Please try using the approach described in this help article Adding and Editing Templates at Runtime.

Greetings,
Kate
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.
0
Stephen
Top achievements
Rank 1
answered on 29 Mar 2013, 02:55 PM
Thanks for the reply.  I took a look at that and it helps but the problem is that  I have a datasource for my main nodes and under each node I want the CheckBoxList.  If I try to set a datasource in the PageLoad instead of harcoding the nodes it doesn't work and it just makes the CheckBoxList the parent node...unless of course I am doing something wrong.

I have a list of Capabilities in the database and a list of Expertise.  Basically I want the tree nodes to be the Capabilities and each Capability should have a CheckBoxList which is populated by the list of Expertise.

So do I have to do all of this in the codebehind?  If so how do I set the datasource of the nodes to be the Capabilities and then have the CheckBoxList under each node?
0
Kate
Telerik team
answered on 03 Apr 2013, 11:09 AM
Hello Stephen,

To be able to apply different templates (or no templates) on the different levels of the nodes it is recommended that you use code behind. Attached to this post you can find a very simplified runnable page that demonstrates how this can be done. Please use the example as a base to implement the desired control in the template and extend it as desired. 

Greetings,
Kate
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.
Tags
TreeView
Asked by
Stephen
Top achievements
Rank 1
Answers by
Kate
Telerik team
Stephen
Top achievements
Rank 1
Share this question
or