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

[Solved] Help! SelectedValue not working

5 Answers 264 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 02 Apr 2008, 01:58 PM
 have a simple rad ComboBox with a value field and a text field.  I bind the combobox to a data source and this works fine.  Now I  want to highlight the selectedvalue.  But I cannot get this to work.  Here is my code:

<Telerik:radComboBox id="cbPolicyAccountValueSource"

DataTextField="value"

DataValueField="key"

runat="server">

</Telerik:radComboBox>

cbPolicyAccountValueSource.DataSource = LifePolicyAccountValue.PolicyAccountValueSources

cbPolicyAccountValueSource.DataBind()


Dim PolicyAccountValueSourceEnumId As Object = DataBinder.Eval(DataItem, "PolicyAccountValueSourceEnumId")


cbPolicyAccountValueSource.SelectedValue = CInt(PolicyAccountValueSourceEnumId)


If I run in debug mode, the above field (PolicyAccountValueSourceEnumId) has the selected value I want the combobox to be selected.  But it is not.  No item is selected.

What am I doing wrong?

Thanks,
Bob

If I run in debug mode, the above field (PolicyAccountValueSourceEnumId) has the selected value I want the combobox to be selected.  But it is not.  No item is selected.What am I doing wrong?Thanks,Bob

5 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 03 Apr 2008, 01:48 PM
Hi Bob,

I suggest that you try the following:

  • Find the item by Value using the FindItemByValue method
  • Select the item by setting its Selected property to true
Hope this helps.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Bob
Top achievements
Rank 1
answered on 03 Apr 2008, 03:51 PM
Nick,

Can you provide an example?  I did a search and nothing useful came back.

Thanks,
Bob
0
Nikolay
Telerik team
answered on 04 Apr 2008, 11:48 AM
Hello Bob,

I prepared a small and running project for you. Attached, please find the files. Download them and give them a go.

Hope this helps.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Bob
Top achievements
Rank 1
answered on 04 Apr 2008, 04:28 PM
I have narrowed down the problem to using the RadComboBox on a user control.  I can set the selectedvalue if the radComboBox is on a web page.  But I am using my radComboBox on a user control that displays when the Edit button on a RadGrid is clicked.  I tried your example and it still did not work when I use it in the user control.   Your example does work on a web page. 

Any ideas?

Thanks,
Bob

0
Nikolay
Telerik team
answered on 07 Apr 2008, 08:09 AM
Hi Bob,

Can you isolate the problem in a small and running project and attach the files to a new support thread? We will test it locally and try to locate the source of the problem. I believe that this would be the best way to proceed.

Expecting your reply,
Nick
the Telerik team

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