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

Getting selected treeview data in combobox

2 Answers 105 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Adrian
Top achievements
Rank 1
Adrian asked on 05 May 2009, 06:37 PM
Hi

I've followed the example on putting a radtreeview in a radcombo box. My datasource for the treeview is from an entitydatasource. The Treeview DataTextField is set to "name" and the DataValueField is set to "ID" of the tree item data.

Im having a problem getting the selected ID of the selected treenode within the combo box.

When i get the .SelectedValue of the combobox it returns the DataTextField of the treeview.
When i get the .SelectedItem.Value of the combobox it returns the DataTextField of the treeview.
When i get the .SelectedItem.Text of the combobox it returns an empty string.

Is this a problem at my end or a bug

Thanks


2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 May 2009, 07:42 AM
Hello Adrian,

You can access the Selected TreeNode value as shown in the code below. You have to access the TreeView and then get its SelectedValue.
c#:
 protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        RadComboBox combo = (RadComboBox)o; 
        RadTreeView treeView = (RadTreeView)combo.Controls[0].Controls[1];         
        string strtxt = treeView.SelectedValue; 
    } 

Thanks
Princy.
0
Veselin Vasilev
Telerik team
answered on 07 May 2009, 02:54 PM
Hi Adrian,

You can find this article helpful:
Finding an item in template

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Adrian
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Veselin Vasilev
Telerik team
Share this question
or