ComboBox saves text instead of value

7 posts, 0 answers
  1. David Price
    David Price avatar
    3 posts
    Member since:
    Aug 2009

    Posted 28 Mar 2013 Link to this post

    I created a ComboBox with a data source of one item (KeyValuePair<string, string>) and set the Value to that one item's value. If I post the page without typing or changing the ComboBox, then the values sent to the server via FormCollection are the Text of the ComboBox, not the Value.
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 01 Apr 2013 Link to this post

    Hello,

    I tried to reproduce the problem on my side but the values seems to be posted as expected. Could you check the attached project and let me know if I am missing something?

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. David Price
    David Price avatar
    3 posts
    Member since:
    Aug 2009

    Posted 03 Apr 2013 Link to this post

    Hi Daniel, 

    Thanks for looking into this. I revised the sample project you attached so you can see the problem I'm having. In my scenario, I'm using the ComboBox to look up names from Active Directory after the user has typed in at least three characters to search on.

    ComboValue V2
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 05 Apr 2013 Link to this post

    Hi again,

    At least in the provided project the DataTextField is set as value to the combobox. Because the item will not be matched and no data is returned with the initial request, the text will be posted. If you wish to show the text and post the value initially, you could set the Value and Text options and prevent the initial binding with the AutoBind method. For convenience I attached the updated project.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. David Price
    David Price avatar
    3 posts
    Member since:
    Aug 2009

    Posted 05 Apr 2013 Link to this post

    It works great except for one small bug. If I click the down arrow on the combo box the text field is replaced by the value.
  7. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 09 Apr 2013 Link to this post

    Hi,

    No results are returned from the server so the combobox will set the value as text. In order to avoid showing the value when opening the dropdown, I can suggest to always send the current text via the request data. I attached the updated project.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Arun
    Arun avatar
    15 posts
    Member since:
    Oct 2014

    Posted 20 Nov 2015 in reply to David Price Link to this post

    Hi David,

    Can you please share code on how to get list of Active Directory names?

    Thank You. 

     

Back to Top
UI for ASP.NET MVC is VS 2017 Ready