0
관련 게시물보기 '만들기': Populating a select box in a form using related ID in MVC3MVC3 채우기가 관련 개체에 대한
나는 투 - 엔티티의 LINQ MVC3와 ADO.NET을 사용하여 생성 된리스트 뷰를 가지고있다.
"관련 객체 생성"을위한 "편집"동작 링크 명령 "작성"&과 함께 간단한 목록보기를 만들 수있었습니다. 내가 만들
@Html.ActionLink("Create Shipping Profile", "../PrintProfile/Create", new { id = item.ProductId }) |
@Html.ActionLink("Edit Shipping Profile", "../PrintProfile/Edit", new { id = item.ProductId })
'PrintProfile' 내가 원하는 나는를 만들 수 있도록, (데이터베이스 테이블 관계 임) "제품 ID '와'사전 인구 '로보기'만들기 ' 프로파일을 작성하고 목록의 각 항목에 대해 연관된 프로파일을 편집하십시오.
public ActionResult Create(int ProductId)
{
var entities = new CS_ShippingProfiles();
entities.ProductId = ProductId; // Assign the ProductId I want to 'create'
return View(entities);
}
[HttpPost]
public ActionResult Create(CS_ShippingProfiles Profile)
{
if (ModelState.IsValid)
{
var entities = new LabelServiceEntities();
entities.AddToCS_ShippingProfiles(Profile);
entities.SaveChanges();
return Redirect("/Products");
}
return View(Profile);
}
하지만이 링크를 따라 할 때, 나는 '널'매개 변수의 예외가 : 여기
는 가 PrintProfile에 대한 컨트롤러 만들기입니다! 내가 도대체 뭘 잘못하고있는 겁니까?! Create
액션에 액션 매개 변수 그래서 당신이 올바른 링크를 생성해야합니다 ProductId
라고
좋은 물건! 감사! 매력처럼 작동합니다. 나중에 도움이되기를 바랍니다. –