0

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; }
    ...
}
melkisadek
  • 1,043
  • 1
  • 14
  • 33

2 Answers2

1

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 !

Joffrey Kern
  • 6,449
  • 3
  • 25
  • 25
1

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

@Html.Action("Index", "Family", new{familyId= Model.familyId })
Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120