How get RadTreeview.SelectedValue in RadcomboBox for another RadComboBox

2 posts, 0 answers
  1. Oosoo
    Oosoo avatar
    2 posts
    Member since:
    Jun 2011

    Posted 21 Jun 2011 Link to this post

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            //RadTreeNOde in Combobox
            function nodeClicking(sender, args) {
                var comboBox = $find("<%= DepartmentCombo.ClientID %>");
                var node = args.get_node()
                // Call comboBox.attachDropDown if:
                // 1) The RadComboBox is inside an AJAX panel.
                // 2) The RadTreeView has a server-side event handler for the NodeClick event, i.e. it initiates a postback when clicking on a Node.
                // Otherwise the AJAX postback becomes a normal postback regardless of the outer AJAX panel.
            function StopPropagation(e) {
                if (!e) {
                    e = window.event;
                e.cancelBubble = true;
            function OnClientDropDownOpenedHandler(sender, eventArgs) {
                var tree = sender.get_items().getItem(0).findControl("RadTreeView1");
                var selectedNode = tree.get_selectedNode();
                if (selectedNode) {
     <telerik:RadComboBox runat="server" ID="DepartmentCombo" Width="100%" OnClientDropDownOpened="OnClientDropDownOpenedHandler"
                            EmptyMessage="Хэлтэс албаны сонгоно уу" ExpandAnimation-Type="None" CollapseAnimation-Type="None"
                            AutoPostBack="true" OnInit="DepComboBox_OnInit">
                                <telerik:RadComboBoxItem Value="0" Text="Хэлтэс албаа сонгоно уу" />
                                <div id="div1">
                                    <telerik:RadTreeView runat="server" ID="RadTreeView1" OnClientNodeClicking="nodeClicking" Width="100%" Height="240px">
                        <script type="text/javascript">
                            var divitem = document.getElementById("div1");
                            if (null != divitem)
                                divitem.onclick = StopPropagation;

    when i postback and get RadTreeview1.selectedvalue  all working perfectly
    RadTreeView RadTree = (RadTreeView)DepartmentCombo.Items[0].FindControl("RadTreeView1");

    but when i get RadTreeview1.selectedvalue in PositionCombo i get msg "Input string was not in a correct format"
    <telerik:RadComboBox runat="server" ID="PositionCombo" Width="100%" EmptyMessage="Албан тушаалаа сонгоно уу"
                            EnableLoadOnDemand="True" ShowMoreResultsBox="true" Height="150px" EnableVirtualScrolling="true"
                            OnItemsRequested="PositionCombo_ItemsRequested" LoadingMessage="Ачааллаж байна...">
                                <table style="width: 100%" cellspacing="0" cellpadding="0">
                                    <tr style="color: #417CAB; font-weight: bold;">                                   
                                        <td style="width: 100%;">
                                <table style="width: 100%" cellspacing="0" cellpadding="0">
                                        <td style="width: 100%;">
                                            <%# DataBinder.Eval(Container, "Text")%>

    protected void PositionCombo_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
                RadTreeView RadTree = (RadTreeView)DepartmentCombo.Items[0].FindControl("RadTreeView1");          
                int ComboID = Convert.ToInt32(DepartmentCombo.SelectedValue); //0
                int TReeID = Convert.ToInt32(RadTree.SelectedValue);//Input string was not in a correct format
                DataTable data = _DepClass.GetPositionListForCbx(TReeID);
                int itemOffset = e.NumberOfItems;
                int endOffset = Math.Min(itemOffset + 500, data.Rows.Count);
                e.EndOfItems = endOffset == data.Rows.Count;
                for (int i = itemOffset; i < endOffset; i++)
                    RadComboBoxItem tempIT = new RadComboBoxItem();
                    tempIT.Value = data.Rows[i]["id"].ToString();
                    tempIT.Text = data.Rows[i]["title"].ToString();
                e.Message = GetStatusMessage(endOffset, data.Rows.Count);

    PS: Sorry my English is bad :).
  2. Dimitar Terziev
    Dimitar Terziev avatar
    1268 posts

    Posted 25 Jun 2011 Link to this post

    Hi Oosoo,

    The reason for your problem is due to fact that when ItemRequested event is fired, a callback to the server is made and not a post-back. When this load on demand technique is used you could not access the current values of other controls on the page since they are not send to the server. 

    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top