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

Treeview in ComboBox selectedvalue empty

1 Answer 95 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Roy
Top achievements
Rank 1
Roy asked on 26 Jul 2011, 11:09 AM

When a node of the treeview (in a combobox) is clicked, the text and value of this node is set to the selected item of the combobox. client side this works well. serverside the selectedvalue is rondomly empty.

function
nodeClicking(sender, args) {

 

 

var comboBox = $find("<%= cbEmployees.ClientID %>");

 

 

var node = args.get_node()

 

comboBox.set_text(node.get_text());

comboBox.trackChanges();

 

var item = comboBox.get_items().getItem(0);

 

item.set_value(node.get_value());

item.set_text(node.get_text());

comboBox.commitChanges();

comboBox.hideDropDown();

comboBox.attachDropDown();

}

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Jul 2011, 01:41 PM
Hello Roy,

Here in this scenario the SelectedIndexChangedEvent won't fire because there is only one item that is TreeView and one approach is to access the comboboxtext that you set from the clientside.
JS:
<script type="text/javascript">
function nodeClicking(sender, args)
{
  var comboBox = $find("<%= cbEmployees.ClientID %>");
  var node = args.get_node()
  comboBox.set_text(node.get_text());
  comboBox.trackChanges();
  comboBox.get_items().getItem(0).set_text(node.get_text());
  comboBox.commitChanges();
  comboBox.hideDropDown();
}
</script>
C#:
protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = "You selected " + cbEmployees.Text;
    }

Thanks,
Shinu.
Tags
ComboBox
Asked by
Roy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or