This is a migrated thread and some comments may be shown as answers.

[Solved] problem getting radcombobox selecteditem value

1 Answer 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 18 Apr 2008, 09:32 PM
I have a combobox with enableonload ="true" (I am using Prometheus)
when i go to my page with the combo i want the user to see the value in the database for the corresponding combo.
I do a RadcomboBox.Text = value from the database.
 # - I want to set the value here as well but I don't know a way of doing that here.
 
After the user selects something from the combo and make other changes, and clicks the update button...on postback my combobox becomes empty.
However I can still  do RadComboBox.Text and get the newly selected text but i cannot get the value corresponding to that.

# - why does my comboBox become empty
# - why can't i get the value field

Please help me with this issue.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 22 Apr 2008, 06:34 AM
Hello there,

When the combobox items are loaded on demand via callback, the items are loaded only at the client-side. Therefore, the items disappear after a postback as these items have never been added to the server. You can, however, access the text and value of the selected item at the server side, like:

RadComboBox1.Text
RadComboBox1.SelectedValue

If you want to select a certain item when the combobox loads, I suggest that you use client-side approach. For example, you can hook on the OnClientLoad event of the combobox, find the item and select it like:

function OnClientLoadEventHandler(sender)
{
     var item = sender.findItemByText("text");
     if(item)
       item.select();
}

Hope this helps.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
newbie
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or