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

Passing ID to the server

2 Answers 72 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 1
Andy Green asked on 23 Dec 2009, 10:33 AM
Going through this example
http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx?product=treeview
of using the TreeView inside a RadCombo, Its the text values that is sent to the server, how would I get the ID to the serverside. I have added the autopostback = true as depending on the ID I have to do other things.

Andy

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Dec 2009, 01:57 PM
Hi Andy,

I guess you want to retrieve the selected node's value in server side. If so one suggestion will be accessing the RadTreeView and get the node which is selected to access the value.

CS:
 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        RadComboBox1.Items[0].Text = RadComboBox1.Text; 
        RadTreeView treeview = (RadTreeView)RadComboBox1.Items[0].FindControl("RadTreeView1"); 
        RadTreeNode node = (RadTreeNode)treeview.SelectedNode; 
        Label1.Text = node.Value; 
 
    } 

-Shinu.
0
Andy Green
Top achievements
Rank 1
answered on 23 Dec 2009, 02:21 PM
Thanks Shinu.

This is great where I need the ID there and then, but I also have a situation where I wont need the ID until the form is submitted.

How would I modify the Javascript function provided in the example to put an ID / Name into the Rad Combo box. Then I can use the me.radcombobox.selectedvalue ect..... and it will save a postback when the user selects a value.

This is the function as provided by your selves:
        function nodeClickingLocation(sender, args)  
        {  
            var comboBox = $find("<%= txtLocation.ClientID %>");  
            var node = args.get_node()  
            comboBox.set_text(node.get_text());  
            comboBox.trackChanges();  
            comboBox.get_items().getItem(0).set_value(node.get_text());  
            comboBox.commitChanges();  
            comboBox.hideDropDown();  
        } 

Also
The controls seem to ignore AJAX, in that they do a full page refresh. Originally I had all the control in a RadAjaxPanel, but I've changed to a RadAjaxManager, but it the same either way, any ideas.

Andy
Tags
TreeView
Asked by
Andy Green
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Andy Green
Top achievements
Rank 1
Share this question
or