0

I have a form that I binding to that has the following structure:

public class Status
{
   public List<ABCAttachment> ABCAttachments_Files { get; set; }
}

public class Attachment
{
  public string Id { get; set; }
}

public class ABCAttachment : Attachment
{
   string Name { get; set; }
}

My action looks like this:

public ActionResult SaveAttachment(Status status)
{
  ....
}

The data is coming over in the form

ABCAttachments_Files[0].Id="0", ABCAttachments_Files[0].Name="test" 

When I access status in my SaveAttachments action the Id is there, but the Name is not. I see it correctly being posted, but why is it not binding properly?

amurra
  • 15,221
  • 4
  • 70
  • 87

1 Answers1

1

Looks like the Name property needs to be public or it won't be bounded to:

public class ABCAttachment : Attachment
{
   string Name { get; set; }
}

should be

public class ABCAttachment : Attachment
{
   public string Name { get; set; }
}
amurra
  • 15,221
  • 4
  • 70
  • 87