I have a field that is generated for each row in the view as follows:
@Html.DropDownListFor(m => m.MenuParentKey, ViewBag.MenuKeys as SelectList)
But I want the drop-down to be populated for each row individually, by calling an action in the controller, here is what I mean:
public ActionResult GetMenuKeys(string currentMenuKey)
{
var dictionary = MenuKeys.Where(mk => mk.Key != currentMenuKey);
return View(new SelectList(dictionary,
"Key",
"Value",
Page.DefaultParentKey));
}
currentMenuKey should be provided according to current row, I want the value of the current row to be excluded from the drop-down (notice it's the parent-key property).