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

RadComboBox Value not set - takes Text instead

4 Answers 238 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Damian Chen
Top achievements
Rank 1
Damian Chen asked on 25 Jan 2010, 05:29 AM
I have the followin radcombobox, where there is a text I wish to display in the dropdown, and a value i will to save in the database:

 

<telerik:RadComboBox EnableTextSelection="false" ID="RadComboBoxForm" Skin="Office2007" CollapseAnimation-Type="InCubic" ExpandAnimation-Type="OutCubic" runat="server" SelectedValue='<%# Eval( "FormTypeId" ) %>' Text='<%# Bind( "FormTypeId" ) %>'>

 

 

<Items>

 

 

<telerik:RadComboBoxItem runat="server" Text="" Value="" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Caplet" Value="1" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Capsule" Value="2" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Controlled Release" Value="3" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Elixir" Value="4" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Ointment" Value="5" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Solution" Value="6" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Supplement" Value="7" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Suspension" Value="8" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Syrup" Value="9" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Tablet" Value="10" />

 

 

</Items>

 

 

</telerik:RadComboBox>

I am databinding, and I have an integer key awaiting the value of the radcombo in the database.  I am finding that it is finding the text value and not the "Value" of the radcombobox which is an integer.  Is there any way to store the integer value in the database instead ?

 

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 25 Jan 2010, 03:58 PM
Hi Damian Chen,

Do you use the SelectedValue property to get the value of the combobox? What does your query look like?

Also, you can omit binding the Text property - if you bind the SelectedValue - it will update the Text automatically.

Greetings,
Veskoni
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Damian Chen
Top achievements
Rank 1
answered on 26 Jan 2010, 09:16 PM
Thanks for that suggestion - omitting the Text attribute did the trick.  Thank you so much.
0
Allen
Top achievements
Rank 2
Iron
Veteran
answered on 30 Jun 2011, 07:24 PM
But what if you want to allow EITHER  a number to be entered directly or picked from a list?  Doesn't seem to bind the value back to the viewmodel property.  Property is the value of RadDataPager.PageSize
0
Dimitar Terziev
Telerik team
answered on 06 Jul 2011, 08:33 AM
Hello Allen,

The scenario that you are trying to implement is not supported. You could not use the text entered in the input as you are using the selected value. However you could retrieve this text on the server-side and then use it to manipulate the data source.

If I'm missing something in your scenario, please open a support ticket and provide us with more information about your particular implementation.

Kind regards,
Dimitar Terziev
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
ComboBox
Asked by
Damian Chen
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Damian Chen
Top achievements
Rank 1
Allen
Top achievements
Rank 2
Iron
Veteran
Dimitar Terziev
Telerik team
Share this question
or