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

Can't set value in DropDownList/ComboBox

1 Answer 253 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 18 Apr 2013, 12:20 PM
 Hi,

I'm upgrading the kendo to the new one (Spring) and after that, I can't set the selected value for DropDown and Combobox. 
It was ok before when i'm using the old version.
And its happen not only in chrome, but in all browser.

I'm using Visual Studio 2012 (MVC 4), and the new Jquery (1.9.1) and JQuery.Validate.Min.js

following is the code snippet:
@(Html.Kendo().DropDownList()
.Name("color")
.DataTextField("Text")
.DataValueField("Value")
.Value("2")
.BindTo(new List<SelectListItem>() {
new SelectListItem() {
Text = "Black",
Value = "1"
},
new SelectListItem() {
Text = "Orange",
Value = "2"
},
new SelectListItem() {
Text = "Grey",
Value = "3"
}
})
)

It always selects  1 instead of 2?!

Any ideas why?

Thanks :)

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 19 Apr 2013, 08:45 AM
Hello Benjamin,


To set the value in the current scenario, you should set it after binding the DropDown to the List of items.
E.g.
@(Html.Kendo().DropDownList()
  ...
  .BindTo(new List<SelectListItem>() {
      new SelectListItem() {
          Text = "Black",
          Value = "1"
      },
      new SelectListItem() {
          Text = "Orange",
          Value = "2"
      },
      new SelectListItem() {
          Text = "Grey",
          Value = "3"
      }
  })
  .Value("3")

 

Greetings,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or