I'm trying to figure out how to populate a dropdown list when editing a ListView item. I'm binding to a ViewModel that contains an IEnumerable<SelectListItem>. On other pages without a ListView, I do something like below, however I'm not sure what action I can use to set up the model so that I have access to it when editing using the ListView. I tried looping through each item in the Read action and setting States there, which is definitely inefficient, but regardless didn't work. Any ideas?
public
IActionResult Index()
{
var model = _service.FindById(1));
model.States = (_lookupService.GetStates());
return
View(model);
}
<
select
asp-for
=
"StateId"
asp-items
=
"Model.States"
class
=
"form-control"
>
<
option
value
=
""
></
option
>
</
select
>