Hi, Telerik,
I'd used code at this link: http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx to create a ComboBox with TreeView inside. (Load Category Table from Database)
But I don't know how to set the default selected value for this RadComboBox when page was loaded.
Ex: Something like this:
Dim myRadComboBox As RadComboBox
myRadComboBox.Selectedvalue = "My Node ID"
Thanks for your support.
I'd used code at this link: http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx to create a ComboBox with TreeView inside. (Load Category Table from Database)
But I don't know how to set the default selected value for this RadComboBox when page was loaded.
Ex: Something like this:
Dim myRadComboBox As RadComboBox
myRadComboBox.Selectedvalue = "My Node ID"
Thanks for your support.
12 Answers, 1 is accepted
0
Hi Tan Le,
You can select a RadComboBox on client pageLoad function with this code:
Find the full code in the attached .zip file.
Please let me know if this was helful.
Greetings,
Veronica Milcheva
the Telerik team
You can select a RadComboBox on client pageLoad function with this code:
function
pageLoad() {
var
comboBox = $find(
"<%= RadComboBox1.ClientID %>"
);
var
tree = comboBox.get_items().getItem(0).findControl(
"RadTreeView1"
);
var
node = tree.findNodeByText(
"South Africa"
);
node.set_selected(
true
);
var
selectedNode = tree.get_selectedNode();
if
(selectedNode) {
comboBox.set_text(selectedNode.get_text());
}
}
Find the full code in the attached .zip file.
Please let me know if this was helful.
Greetings,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Tan
Top achievements
Rank 2
answered on 09 Aug 2010, 09:57 AM
Hi., Veronica Milcheva.
Thanks for your support. This code is all my need. But I am using controls dynamic generation form in my code (DotNetNuke Framework), I didn't use drag and drop method instead I generate RadComboBox TreeView in my code behind ,so I couldn't knows the exactly what the name of the RadControl.ClientID and the name of TreeView which inside it.
May be I used this code for Page.ClientScript.RegisterStartupScript to solve my problem.
Is there another ways to do this ?
And I'm waiting your solution.
Thanks again.
P/s: My English is not good, pay compassion to me.
Thanks for your support. This code is all my need. But I am using controls dynamic generation form in my code (DotNetNuke Framework), I didn't use drag and drop method instead I generate RadComboBox TreeView in my code behind ,so I couldn't knows the exactly what the name of the RadControl.ClientID and the name of TreeView which inside it.
May be I used this code for Page.ClientScript.RegisterStartupScript to solve my problem.
Is there another ways to do this ?
And I'm waiting your solution.
Thanks again.
P/s: My English is not good, pay compassion to me.
0
Hi Tan Le,
Thanks for contacting us again.
You can use the OnClientLoad event of the RadComboBox instead of pageLoad. That way you can get the combo client-side object via the sender parameter. Here's the code:
Please let me know if this was helpful.
Greetings,
Veronica Milcheva
the Telerik team
Thanks for contacting us again.
You can use the OnClientLoad event of the RadComboBox instead of pageLoad. That way you can get the combo client-side object via the sender parameter. Here's the code:
function
clientLoad(sender, args) {
var
comboBox = sender;
var
tree = comboBox.get_items().getItem(0).findControl(
"RadTreeView1"
);
var
node = tree.findNodeByText(
"South Africa"
);
node.set_selected(
true
);
var
selectedNode = tree.get_selectedNode();
if
(selectedNode) {
comboBox.set_text(selectedNode.get_text());
}
}
Please let me know if this was helpful.
Greetings,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Tan
Top achievements
Rank 2
answered on 13 Aug 2010, 07:40 AM
Ok, thanks you. It work for me.
0

ARUN RAJA
Top achievements
Rank 1
answered on 23 Mar 2011, 12:56 PM
Hello friend,
i need this function in server side(c#).i can able to set the selected node of tree view in code behind but not able to set the selected node as default dropdown value.
By
arun
i need this function in server side(c#).i can able to set the selected node of tree view in code behind but not able to set the selected node as default dropdown value.
By
arun
0
Hi ARUN,
You can set default item of the ComboBox server-side by this code for example:
In my case I have a node in the RadTreeView with text "Canada".
Please let me know if this was helpful.
Greetings,
Veronica Milcheva
the Telerik team
You can set default item of the ComboBox server-side by this code for example:
protected
void
Page_Load(
object
sender, EventArgs e)
{
RadTreeView tree = (RadTreeView)RadComboBox1.Items[0].FindControl(
"RadTreeView1"
);
var node = tree.FindNodeByText(
"Canada"
);
node.Selected =
true
;
}
In my case I have a node in the RadTreeView with text "Canada".
Please let me know if this was helpful.
Greetings,
Veronica Milcheva
the Telerik team
0

Karthik Kantharaj
Top achievements
Rank 1
answered on 17 Jun 2011, 07:24 AM
Hi Veronica Milcheva
I am following your post, i got the selected node in tree but am not able to place my tree node to combobox
Below is my code on server side
ComboBox cbx = (ComboBox)control.FindControl("RadComboBox1");
RadTreeView objTree1 = (RadTreeView)cbx.Items[0].FindControl("RadTreeView1");
RadTreeNode nodeValue = objTree1.FindNodeByValue(id.ToString());
nodeValue.Selected = true;
What i need to do after this
/*
bool selectedNode = nodeValue.Selected;
if(selectedNode)
{
cbx.SelectedValue = nodeValue.Value;
}
*/
Please guide me
Karthik.K
I am following your post, i got the selected node in tree but am not able to place my tree node to combobox
Below is my code on server side
ComboBox cbx = (ComboBox)control.FindControl("RadComboBox1");
RadTreeView objTree1 = (RadTreeView)cbx.Items[0].FindControl("RadTreeView1");
RadTreeNode nodeValue = objTree1.FindNodeByValue(id.ToString());
nodeValue.Selected = true;
What i need to do after this
/*
bool selectedNode = nodeValue.Selected;
if(selectedNode)
{
cbx.SelectedValue = nodeValue.Value;
}
*/
Please guide me
Karthik.K
0
Hi Karthik Kantharaj
Please note that by selecting the RadTreeNode in the Page_Load event (the same code as in my previous post) - this will be enough to view this selected node in the input of the comobobox.
Please let me know if I am missing something in your requirement?
Kind regards,
Veronica Milcheva
the Telerik team
Please note that by selecting the RadTreeNode in the Page_Load event (the same code as in my previous post) - this will be enough to view this selected node in the input of the comobobox.
Please let me know if I am missing something in your requirement?
Kind regards,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Karthik Kantharaj
Top achievements
Rank 1
answered on 23 Jun 2011, 11:42 AM
Hi Veronica Milcheva
Thank you
ComboBox cbx = (ComboBox)ouSelectors.FindControl("RadComboBox1");
RadTreeView objTree1 = (RadTreeView)cbx.Items[0].FindControl("RadTreeView1");
RadTreeNode nodeText = objTree1.FindNodeByText(org.Name);
nodeText.Selected = true;
cbx.Text = nodeText.Text;
is what i added and tested and worked fine
The only difference is that i did no do in page_load i did in button click
This is what i added can you please test because i did on server side
Karthik.K
Thank you
ComboBox cbx = (ComboBox)ouSelectors.FindControl("RadComboBox1");
RadTreeView objTree1 = (RadTreeView)cbx.Items[0].FindControl("RadTreeView1");
RadTreeNode nodeText = objTree1.FindNodeByText(org.Name);
nodeText.Selected = true;
cbx.Text = nodeText.Text;
is what i added and tested and worked fine
The only difference is that i did no do in page_load i did in button click
This is what i added can you please test because i did on server side
Karthik.K
0
Hi Karthik Kantharaj,
Yes, you are absolutely right that on server-side you need to set the Text of the RadComboBox in order to display the selected node in the input field of the RadComboBox. Thank you for this remark and please accept my apologies for misleading you.
Greetings,
Veronica Milcheva
the Telerik team
Yes, you are absolutely right that on server-side you need to set the Text of the RadComboBox in order to display the selected node in the input field of the RadComboBox. Thank you for this remark and please accept my apologies for misleading you.
Greetings,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Karthik Kantharaj
Top achievements
Rank 1
answered on 02 Aug 2011, 05:39 AM
Hi Veronica Milcheva
Sorry for delay
Thank you for your support
Karthik.K
Sorry for delay
Thank you for your support
Karthik.K
0

Mehrdad
Top achievements
Rank 1
answered on 28 Nov 2011, 11:56 AM
hi
Plz Help :(
node.Selected =
true
;
Node is null Plz Help :(