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

Selecting an item in ComboBox With TreeView

4 Answers 150 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mehrdad
Top achievements
Rank 1
Mehrdad asked on 28 Nov 2011, 07:46 AM
hi : 
My English is not very good,, sorry , I've spoke Persian
I have a Combobox and in combobox There are TreeView . 
treeview Connected to SQLDATASOURCE1 ...

I need the id of an item from the tree to the combobox . 
Id Saved To Dattabase ,
how Access to TreeView and Selected Item in TreeView ,

Thanks a lot


4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Nov 2011, 10:31 AM
Hello Mehrdad,

Try the following code snippet.
C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    RadComboBox combo = (RadComboBox)sender;
    RadTreeView tree = (RadTreeView)combo.FindControl("RadTreeView1");
    string value = tree.SelectedNode.Text;
}

Thanks,
Princy.
0
Mehrdad
Top achievements
Rank 1
answered on 28 Nov 2011, 10:53 AM
Dear Friend!
i want to search an id of a node of a treeview in item template of combobox, then show it's text and value as a combobox item.
sorry your code doesn't help me. i don't want use a control id.
0
Mehrdad
Top achievements
Rank 1
answered on 28 Nov 2011, 12:19 PM
hi : 
this code is true , but nod is null . whey ? 
datatable dt = account.SelectRow(Request.QueryString["Guid"].ToString().Trim());
RadTreeView tree = ddlName.Items[0].FindControl("RadTreeView1") as RadTreeView;
RadTreeNode nod = tree.FindNodeByValue(dt.Rows[0]["did"].ToString());
nod.Selected = true;


plz help
0
Ivana
Telerik team
answered on 30 Nov 2011, 02:58 PM
Hi Mehrdad,

Make sure that there is an item in the RadTreeView, which value is set to the value of the following expression: dt.Rows[0]["did"].ToString().

You could refer to the following help article for more information of how RadTreeView's items could be found: RadTreeView: Server-Side Programming Basics.
The following help article might be of help, too: RadComboBox: Accessing Controls Inside Templates.

I hope this helps.

Greetings,
Ivana
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
ComboBox
Asked by
Mehrdad
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mehrdad
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or