I am trying to create a partialview for my dropdownlistbox in my asp.net mvc 3 application.
in my page I have:
@Html.Action("PopulateCombo","ComboController")
controller partialview:
public ActionResult PopulateCombo()
{
//some code here to organise data and maybe some caching
return ItemsForCombo;
}
Is there a better way of templating a Dropdownlistbox?
I would populate the data in the controller, then pass it to a model and finally use an
Html.DropDownListFor. I mean, that’s what MVC stands for 🙂Example
(PS: it’s been quite a while since I not code in c# anymore so apologies for any kind of typo)
controller.cs
model.cs
index.cshtml