I have created an sample which works fine.Please try like that
public class TestController : Controller
{
public ActionResult Index()
{
ViewBag.StatusList =
DropDownList<Status>.LoadItems(GetData(), "StatusId", "Name");
return View();
}
public ActionResult _PartialView()
{
return PartialView();
}
public List<Status> GetData()
{
var list = new List<Status> {new Status() {StatusId = 1, Name = "AAA"}};
return list;
}
}
public class Status
{
public decimal StatusId { get; set; }
public string Name { get; set; }
}
public class MyViewModel
{
public int StatusId { get; set; }
}
public static class DropDownList<T>
{
public static SelectList LoadItems(IList<T> collection, string value, string text)
{
return new SelectList(collection, value, text);
}
}
Partial View code
@model MvcApplication1.Controllers.MyViewModel
@Html.DropDownListFor(model => model.StatusId, (IEnumerable<SelectListItem>)ViewBag.StatusList, "--Select--", new { @class = "select" })
Index View
@model MvcApplication1.Controllers.MyViewModel
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@Html.Partial("_PartialView")
Note: Please make sure that partial view should be inside of View>>Test>> folder
Hope this helps