Getting selected treeview data in combobox

3 posts, 0 answers
  1. Adrian
    Adrian avatar
    81 posts
    Member since:
    Aug 2006

    Posted 05 May 2009 Link to this post

    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. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 May 2009 Link to this post

    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.
  3. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 07 May 2009 Link to this post

    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.
Back to Top