I am trying to set the selected value of the combobox/treeview from a database value. The online example of a treeview in a combobox works great for insert and select operations but if i try to use it in an edit form i can't seem to properly find the treeview in the combobox and set the selected item to the database field. Any examples out there that explain how to do this?
| <telerik:RadComboBox ID="comboParent" runat="server"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| <ItemTemplate> |
| <div id="divParentProducts"> |
| <telerik:RadTreeView ID="treeParentProducts" runat="server" DataFieldID="ProductID" DataFieldParentID="ParentProductID" |
| DataSourceID="sqlProducts" DataTextField="ProductName" DataValueField="ProductID" OnClientNodeClicking="productClicking" |
| Skin="WebBlue"> |
| <CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation> |
| <ExpandAnimation Duration="100"></ExpandAnimation> |
| </telerik:RadTreeView> |
| </div> |
| </ItemTemplate> |
| <Items> |
| <telerik:RadComboBoxItem Text="" Value="" /> |
| </Items> |
| </telerik:RadComboBox> |
| //Found this in another forum answer what would the "THE _ITEM_VALUE" Be in my scenario |
| RadComboBoxItem comboBoxItem = comboParent.FindItemByValue("THE_ITEM_VALUE"); |
| RadTreeView treeView = (RadTreeView)comboBoxItem.FindControl("treeProductHierarchy"); |
| TreeNode nodetoSelect = parentProducts.FindNode(selected.ParentProductID.ToString()); |
| nodetoSelect.Selected = true; |