프로젝트를 ASP.net Forms에서 ASP.Net MVC Core로 변환 중입니다.여러 행의 데이터 저장 및 게시 ASP.Net MVC
는 다음과 같은 형식을 고려 : 나는 새받는 사람을 만드는거야
을, 그리고받는 사람이 여러 연락처 방법이있을 수 있습니다. 다음 내 ASP.Net에서
내가 리피터를했다, 응용 프로그램을 형성하고, 난 그냥 중계기에 새로운 요소를 추가하고 양식 :
에서 다음 모달납니다 연락 방법 추가 버튼을
제출되었으므로 리피터 행을 반복하고 데이터베이스를 채 웁니다.MVC에서 어떻게합니까? html 테이블을 만들고 그 행을 반복합니까?
저는 MVC를 처음 사용하기 때문에 여기에서 진행하는 방법을 모르겠습니다.
public class Recipient
{
[Key]
public Guid RecipientGUID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Company { get; set; }
public UserGroup Owner { get; set; }
public List<ContactMethod> ContactMethods { get; set; }
public User CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public User LastModifiedBy { get; set; }
public DateTime LastModifiedOn { get; set; }
public bool IsActive { get; set; }
}
연락 방법 :
public class ContactMethod
{
[Key]
[HiddenInput(DisplayValue = false)]
public Guid ContactMethodGUID { get; set; }
[Required(ErrorMessage = "Please specify a type.")]
public ContactMethodType Type { get; set; }
[Required]
public Recipient Recipient { get; set; }
public int CountryCode { get; set; }
[Required(ErrorMessage = "Please enter a identifier.")]
public string Identifier { get; set; }
public bool IsPreferred { get; set; }
}
는 [이 답변]을 참조하시기 ASP.NET MVC 면도기 튜토리얼 (http://stackoverflow.com/questions/28019793/submit-same-partial-view-called-multiple-times를 봐 -data-to-controller/28081308 # 28081308) 컬렉션 항목을 동적으로 추가하는 옵션 –