Treeview in ComboBox selectedvalue empty

2 posts, 0 answers
  1. Roy
    Roy avatar
    1 posts
    Member since:
    Jul 2011

    Posted 26 Jul 2011 Link to this post

    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();

    }

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Jul 2011 Link to this post

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