This is a migrated thread and some comments may be shown as answers.
Problem with selectedItem
2 Answers 21 Views
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 23 Aug 2012, 09:46 PM
Hello,

I'm trying to get the selectedItem from the comboBox but since I load it up with info from a string on the server side it wont do anything.
The items are there however on both the server side and client side they seem empty.

Here's the asp control:
<telerik:RadComboBox
                 ID="RadComboBox1" runat="server"
                 Width="590px" Height="140px"
                 EmptyMessage="Type something here"
                 OnItemsRequested="RadCombobox2_ItemsRequested" EnableLoadOnDemand="true"
                 >
</telerik:RadComboBox>
And the .cs
protected void RadCombobox2_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
    {
        for(int i=0;i<mono.M_content.Count;i++)
        {
            if (mono.M_content[i].M_type == 0)
            {
                RadComboBox1.Items.Add(new RadComboBoxItem(mono.M_content[i].C_Description.ToString()));
            }
        }
    }
 
protected void Button1_Click(object sender, EventArgs e)
    {
        label12.Text = RadComboBox1.SelectedValue.ToString();
        //RadEditor1.Content = test;
    }

I load the ComboBox with info from a database and I have a button which is supposed to paste that info into the RadEditor but I won't do anything, I've tried all the event handlers from the ComboBox without success, I still get nothing, not even an error.

Any ideas on how I can fix this?

Thanks a lot for your help.

Greetings

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivana
Telerik team
answered on 24 Aug 2012, 05:48 AM
Hi Jonathan,

The items loaded on demand are not accessible on the server. The following help article explains more on the matter: http://www.telerik.com/help/aspnet-ajax/combobox-load-on-demand-access-items-server-side.html.

If you, however, need to set an item as selected when a set of items has been loaded from the server, you could use the OnClientItemsRequested event which is fired just after the items are fetched from the server.

Regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jonathan
Top achievements
Rank 1
answered on 24 Aug 2012, 05:17 PM
Hello,

Thanks a lot for your reply, while that specific script didn't solve the problem I had, the insight on the fact that you can't get the items on the server help me figure out a script that would let me do what I wanted which was to copy the selected item in the combo box to the editor.

I'll paste it here in case someone has the same problem:

<script language="javascript" type="text/javascript">
            function OnClientSelectedIndex(sender, eventArgs) {
                var editor = $find("<%=RadEditor1.ClientID%>");
                editor.pasteHtml(sender.get_text());
            }
 </script>

Cheers!
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Jonathan
Top achievements
Rank 1
Share this question
or