0

I have the following razor code:

<div class="value"> @Html.DropDownListFor(
                       model => model.physicalAtributtes.bloodGroup,
                       new SelectList(Model.physicalAtributtes.BloodGroups)
                    ) 
</div>

And I have the following Model:

public class Donor
{
    public PersonalData personalData { get; set; }
    public PhysicalAtributtes physicalAtributtes { get; set; }
}

public class PersonalData
{
    public string name { get; set; }
    public string adress { get; set; }
    public DateTime birthDate { get; set; }
    public string bornCity { get; set; }
    public string citizenIdentifier { get; set; }
    public string nationality { get; set; }
    public string profession { get; set; }
    public string academicDegree { get; set; }
    public string maritalStatus { get; set; }
    public int sonsNumber { get; set; }
}

public class PhysicalAtributtes
{
    private ArrayList bloodGroups = new ArrayList { "A+", "A-", "AB+", "AB-", "B+", "B-", "O+", "O-" };

    public double height { get; set; }
    public double weight { get; set; }
    public string skinColor { get; set; }
    public string eyesColor { get; set; }
    public string hairColor { get; set; }
    public string hairTexture { get; set; }
    public string bloodGroup { get; set; }
    public string ethnicity { get; set; }
    public ArrayList BloodGroups { get => bloodGroups; set => bloodGroups = value; }
}

The IISExpress gives the following error and I'm not understanding why:

An unhandled exception occurred while processing the request.

NullReferenceException: Object reference not set to an instance of an object. AspNetCore._Views_Donor_Register_cshtml+d__0.MoveNext() in Register.cshtml, line 96

Anyone have a idea what I'm doing wrong?

Ricardo Rocha
  • 14,612
  • 20
  • 74
  • 130

0 Answers0