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

Selecting First Node from treeview and using to set combobox text and value.

1 Answer 324 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 25 Apr 2011, 01:54 AM
I have a treeview control embeded into a combobox. I am binding the tree to a sqldatasource, Then I select the first child node of the tree and set it as selected and this all works. What I haven't figured out is how to use the selected node of the tree and set the selected text/value of the parent combobox. I'm trying to do this server-side in c#.

Also I would like to have the tree expanded to show the branch of the tree that has the selected node. If the user selects the dropdown then the tree would show the highlighted selected node.

An example would be greatly appreciated.

Thanks,

Marc

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Apr 2011, 10:09 AM
Hello Marc,
Here is a sample code for achieving your first requirement.
C#:
protected void Page_Load(object sender, EventArgs e)
    {
         RadTreeView tree = (RadTreeView)RadComboBox4.Items[0].FindControl("RadTreeView1");
         RadTreeNode node = tree.FindNodeByText("Products");
         node.Selected = true;
         RadComboBox4.Text= node.Text;
    }
aspx:
<telerik:RadComboBox ID="RadComboBox4" runat="server" AllowCustomText="true">
           <ItemTemplate>
               <telerik:RadTreeView ID="RadTreeView1" runat="server">
                   <Nodes>
                       <telerik:RadTreeNode Text="Products">
                       </telerik:RadTreeNode>
                       <telerik:RadTreeNode Text="Services">
                       </telerik:RadTreeNode>
                   </Nodes>
               </telerik:RadTreeView>
           </ItemTemplate>
           <Items>
               <telerik:RadComboBoxItem Text="" />
           </Items>
</telerik:RadComboBox>

I am not quite sure about your second requirement and please elaborate the scenario.

Thanks,
Shinu.
Tags
ComboBox
Asked by
Marc
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or