문제

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?

도움이 되었습니까?

해결책

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; }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top