HomeController > Index action does a select query. For each row in that select query, I need to render a Partial View in my Index view. Since this depends on the database, I'm doing this part of the code from the controller. I searched quite a bit, but I can't figure out how to render a PartialView from the controller.
Do partial views require a controller action? I wasn't sure about this, but this is what I created:
public PartialViewResult ucDropdown(Question question) { ViewBag.Question = question; return PartialView(); }In my main view, how do I call this partial view? I have (unsuccessfully) tried:
public ActionResult Index(string id = "") { var q = ...... var ctrls = new ControlsController(); ViewBag.Questions = ctrls.ucDropdown(q); return View(); }How can I access the ViewBag of this partial view?