Вопрос

I'm trying to pass a value into an Html.Action using FirstOrDefault to return the first entry in an array of values. The value is not picked up and I keep getting a null exception.

The family variable picks up the correct values from the model as a key/value pair.

What do I need to do to pass the zero indexed Value "2" as the parameter in the Action?

Code and debug information:

VisualStudio

----Edit for Code---

Family Index Action

    public ActionResult Index(int familyId)
    {            
        var model = GetDisplay(familyId).OrderByDescending(i => i.dob);
        return PartialView(model);
    }

Family ViewModel

public partial class FamilyListViewModel
{
    public int Id { get; set; }
    public int familyId { get; set; }
    public string name { get; set; }
    ...
}
Это было полезно?

Решение

This is actually a Dictionnary, you have to retrieve the value of your key like this :

@Html.Action("Index", "Family", new { familyId = family["Id"] })

Hope it helps !

Другие советы

Try with the below code and send the familyId parameter as expected by your action

@Html.Action("Index", "Family", new{familyId= Model.familyId })
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top