I have 2 combo boxes with treeviews in them for a States drop down list and when I click a button, I would like the first combobox to copy the value and text to the second one as well as select the appropriate node and expand to it if needed. The combo box is a list of states and then the only parent is Territories which then shows the US territories. The code I have is as follows.
My markup is as follows...
Then code behind is...
I'm having 2 problems... 1 is when i click the button the first time it'll get the text and value from the combo box but on the second time around it's null. 2 is I can't get the second state combobox to set the text and value and the selected item value.
My markup is as follows...
function nodeClicking(sender, args) { var temp = sender._clientStateFieldID.split('_'); if (temp.length >= 1) { var name = temp[0]; var comboBox = $find(name); var node = args.get_node(); comboBox.set_text(node.get_text()); comboBox.trackChanges(); comboBox.get_items().getItem(0).set_text(node.get_text()); comboBox.get_items().getItem(0).set_value(node.get_value()); comboBox.commitChanges(); comboBox.hideDropDown(); } }<div style="width: 100%;"> <tk:RadComboBox ID="rcbState" runat="server" Width="250px" ShowToggleImage="true" EmptyMessage="Choose a State" HighlightTemplatedItems="true" style="vertical-align: middle;" > <ItemTemplate> <div id="div1"> <tk:RadTreeView ID="rtvState" runat="server" OnClientNodeClicking="nodeClicking"> <DataBindings> <tk:RadTreeNodeBinding Expanded="false" /> </DataBindings> </tk:RadTreeView> </div> </ItemTemplate> <Items> <telerik:RadComboBoxItem Text="" /> </Items> </tk:RadComboBox> <asp:Label ID="lblTest" runat="server" /> </div> <div> <tk:RadComboBox ID="rcbState2" runat="server" Width="250px" ShowToggleImage="true" EmptyMessage="Choose a State" HighlightTemplatedItems="true" style="vertical-align: middle;" > <ItemTemplate> <div id="div1"> <tk:RadTreeView ID="rtvState2" runat="server" OnClientNodeClicking="nodeClicking"> <DataBindings> <tk:RadTreeNodeBinding Expanded="false" /> </DataBindings> </tk:RadTreeView> </div> </ItemTemplate> <Items> <telerik:RadComboBoxItem Text="" /> </Items> </tk:RadComboBox> <asp:Label ID="lblTest2" runat="server" /> </div> <div> <tk:RadButton ID="btnTest" runat="server" Text="Submit" OnClick="btnTest_Click" /> </div>Then code behind is...
protected void btnTest_Click(object sender, EventArgs e) { string text = rcbState.SelectedItem.Text; string value = rcbState.SelectedItem.Value; lblTest.Text = "Name = " + text + ", ID = " + value; rcbState2.Text = text; RadTreeView rtv2 = rcbState2.Items[0].FindControl("rtvState2") as RadTreeView; (rtv2.Nodes.FindNodeByValue(value)).Expanded = true; if (rcbState2.SelectedItem != null) { lblTest2.Text = rcbState2.SelectedItem.Text; lblTest2.Text = rcbState2.SelectedItem.Value; } }I'm having 2 problems... 1 is when i click the button the first time it'll get the text and value from the combo box but on the second time around it's null. 2 is I can't get the second state combobox to set the text and value and the selected item value.