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

System.Web.Mvc.SelectList is the selected value

3 Answers 104 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andy Yu
Top achievements
Rank 1
Andy Yu asked on 21 Apr 2011, 08:16 AM
I've got a problem with server side binding on the combobox. 

A select list is created in the controller an it is passed a selected value. The list is passed to the view via a view model and then binded to the combobox via BindTo. The correct item is displayed/selected in the combobox when open the page. The problem is that when I open the combobox it shows the text "System.Web.Mvc.SelectList" which isn't a value that exists in the SelectList!

If I view the source I see that the combobox is initialized with "System.Web.Mvc.SelectList" as the selected value?! 

Is this a bug or am I missing something?
 
I've attached a small sample project that visualizes the problem.


Andy

3 Answers, 1 is accepted

Sort by
0
Jamy
Top achievements
Rank 1
answered on 23 Apr 2011, 04:14 PM
Andy,

Did you find a resolution to this yet?

I just ran into the same problem.Tested with dropdownitem and it also puts the type name as the selected value.
0
Georgi Krustev
Telerik team
answered on 26 Apr 2011, 10:21 AM
Hello,

This happens when the ComboBox UI component and the SelectList collection have same name. The ComboBox tries to find string value ( which will be used to select correct item ) in the ViewData. Hence when ViewData.Eval("Cars") is called then the returned value is "System.Web.Mvc.SelectList". In order to avoid this behavior I will suggest you to change the combobox name.

Best wishes,

Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andy Yu
Top achievements
Rank 1
answered on 28 Apr 2011, 07:53 AM
Thanks Georgi!
That solved my problem!

Regards,
Andy
Tags
ComboBox
Asked by
Andy Yu
Top achievements
Rank 1
Answers by
Jamy
Top achievements
Rank 1
Georgi Krustev
Telerik team
Andy Yu
Top achievements
Rank 1
Share this question
or