Question

I want to create an editor for choosing a number of some country. Meaning, I have to choose a country, use AJAX to load the country's numbers and then choose a number.

The editor initial model is the list of counties. I want to use Editor Templates and NOT give the list of counties model to the template every time I use it.

This is currently what I have:

@model Domain.Entities.NumberX
@Html.EditorFor(m => m.numberX)
@Html.DropDownList("countryNumberX", new SelectList(Model, "CountryId", "Name"))

How can I do it?

Was it helpful?

Solution 2

It appears that the right way will consist of supplying the editor template with initial list of countries.

OTHER TIPS

First things that comes to mind is adding a class in DataLayer with a static collection of Countries and then access it in the editor.

Another way can be having a standard controller for List feeding via ajax. Another way is to have a sort of Helper emitting the Select for you, select list can be builded in the Helper method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top