RadComboBox Value not set - takes Text instead

5 posts, 0 answers
  1. Damian Chen
    Damian Chen avatar
    6 posts
    Member since:
    Sep 2009

    Posted 24 Jan 2010 Link to this post

    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 ?

     

  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 25 Jan 2010 Link to this post

    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.
  3. Damian Chen
    Damian Chen avatar
    6 posts
    Member since:
    Sep 2009

    Posted 26 Jan 2010 Link to this post

    Thanks for that suggestion - omitting the Text attribute did the trick.  Thank you so much.
  4. Allen
    Allen avatar
    89 posts
    Member since:
    Mar 2011

    Posted 30 Jun 2011 Link to this post

    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
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 06 Jul 2011 Link to this post

    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!

Back to Top