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

[Solved] ComboBox support in Razor views?

1 Answer 165 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.
Zeev
Top achievements
Rank 1
Zeev asked on 14 Dec 2011, 05:29 PM

I am new to Telerik MVC and to MVC in general. I am trying to use ComboBox in Razor view and copied your example of usnig combobox in aspx view so I converted the original code of:

 

<%

 

= Html.Telerik().ComboBox()

 

.Name(

 

"Categories")

 

.SelectedIndex(-1)

.BindTo(

 

new SelectList(Model, "CategoryID", "CategoryName"))

 

.ClientEvents(events => events.OnChange(

 

"categoryChanged"))

 

%>

 

 

to

 

@Html.Telerik().ComboBox()

.SelectedIndex(-1)

.BindTo(new SelectList(Model.PropertyTypes, "ID", "Name"))

 in my Razor View.

 

When I run it I get an exception deep down in telerik xource code in ViewComponentBase.cs in the method

 

VerifySettings() complaining the Name variable is null ?

Can you show me a code snipet how to bind ComboBox in Razir views ?

 

Thanks
Zeev

1 Answer, 1 is accepted

Sort by
0
Doogle
Top achievements
Rank 1
answered on 13 Jan 2012, 10:00 PM
In your translation effort, you forgot to add the name parameter.

Try this:

@Html.Telerik().ComboBox()

.Name("Categories")
.SelectedIndex(-1)

.BindTo(new SelectList(Model.PropertyTypes, "ID", "Name"))

Tags
ComboBox
Asked by
Zeev
Top achievements
Rank 1
Answers by
Doogle
Top achievements
Rank 1
Share this question
or