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

ComboBox saves text instead of value

6 Answers 255 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
David Price
Top achievements
Rank 1
David Price asked on 28 Mar 2013, 03:19 PM
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.

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 01 Apr 2013, 09:46 AM
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!
0
David Price
Top achievements
Rank 1
answered on 03 Apr 2013, 01:32 PM
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
0
Daniel
Telerik team
answered on 05 Apr 2013, 09:42 AM
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!
0
David Price
Top achievements
Rank 1
answered on 05 Apr 2013, 08:31 PM
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.
0
Daniel
Telerik team
answered on 09 Apr 2013, 01:57 PM
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!
0
Arun
Top achievements
Rank 1
answered on 20 Nov 2015, 03:53 PM

Hi David,

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

Thank You. 

 

Tags
ComboBox
Asked by
David Price
Top achievements
Rank 1
Answers by
Daniel
Telerik team
David Price
Top achievements
Rank 1
Arun
Top achievements
Rank 1
Share this question
or