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

Setting selected item in code behind?

3 Answers 203 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
scrut
Top achievements
Rank 1
scrut asked on 04 Jul 2008, 01:37 PM
Hi everyone,

I have a simple RadComboBox like this one where a user can make a selection which is then saved in a database.

When the user comes back later, the value/text he selected is read from the DB and should initially be displayed in the combo box text field - still allowing him to make further alterations. With Prometheus 415 things worked but since upgrading to 619, the combo box text field remains empty initially. When the user clicks the drop-down-arrow, the list is filled correctly and the item he previously selected is highlighted as it should be.
But why is the text box white when the page first loads? It should show the selection the user made before.

Here's what I did:

My ComboBox:

<telerik:RadComboBox ID="TypeOfActionRadComboBox" runat="server" DataSourceID="TypeOfActionObjectDataSource" Skin="Outlook" Width="300px" DataTextField="name" DataValueField="tid">  
    <CollapseAnimation Duration="200" Type="OutQuint" /> 
</telerik:RadComboBox> 

Portion of code-behind (the type_of_action_id is set correctly to a valid int value)
this.TypeOfActionRadComboBox.SelectedItem.Value = this.type_of_action_id.ToString(); 

I also tried with ...RadComboBox.SelectedValue = ... but that didn't work either.

Any ideas?

Thanks

s.

3 Answers, 1 is accepted

Sort by
0
Stuart Hemming
Top achievements
Rank 2
answered on 04 Jul 2008, 03:17 PM
Hi there.

Let me answer your question with a question: have you got FormDecorator on the page?

If you have you should get along to the FormDecorator forum and read the topmost article.

I had this same problem but the workarounds published in the above thread fixed it for me.

Hope this helps.

--
Stuart
0
scrut
Top achievements
Rank 1
answered on 05 Jul 2008, 07:41 PM
Indeed, it did help. Thanks a lot!
s.
0
Steven
Top achievements
Rank 2
answered on 08 Jul 2008, 10:32 AM
Thanks alot. Fix nr 4 did the trick for me aswell for the problem the rad combobox did not show the first value in the list in IE.
Tags
ComboBox
Asked by
scrut
Top achievements
Rank 1
Answers by
Stuart Hemming
Top achievements
Rank 2
scrut
Top achievements
Rank 1
Steven
Top achievements
Rank 2
Share this question
or