1
저는 MVC에 관해 아주 새로워졌습니다. 나는 다음과 같은 모델 클래스가 있습니다MVC4 : 모델의 인터페이스 객체
public class Store
{
public PriceList PriceListInfo { get; set; }
public IStore storeData;
}
public class PriceList
{
public int id { get; set; }
public string codice { get; set; }
}
public interface IStore
{
[...]
}
public class Silo2Store : IStore
{
public int S2 { get; set; }
public int S3 { get; set; }
}
을 그리고 난 내보기에이 모델을 사용합니다 :
public ActionResult Customer()
{
using (Store t = (Store)Session["Store"])
{
if (t.PriceListInfo == null)
{
t.PriceListInfo = new PriceList();
}
t.PriceListInfo.codice = "XXX";
return View(t);
}
}
내가 싶습니다
@model Store
@Html.TextBoxFor(model => ((Silo2Store)Model.storeData).S3)
해당 컨트롤러 방법은 내 컨트롤러에서 모델 검색 :
[HttpPost]
public ActionResult Customer(Store modelStore)
{
var test = ((Silo2Store)Model.storeData).S3;
}
이지만 Model.storeData
속성은 내보기에서 초기화되지 않았습니다. null
입니다. 그런 다음 내 컨트롤러에서 값을 검색 할 수 없습니다.
어쨌든 내 모델을 변경해야합니까?
GET 컨트롤러 메소드의 코드를 표시 할 수 있습니까? –
'공공 ActionResult 고객() { 사용 (스토어 t = (스토어) 세션 [ "스토어"]) { 경우 (t.PriceListInfo == NULL) { t.PriceListInfo = 새로운 가격표() ; } t.PriceListInfo.codice = "XXX"; 돌아 가기 뷰 (t); } } ' – gorgonzola
..보기에서 내 모델을 확인할 때 (디버그 모드에서) 개체 "storeData"가 null이 아닙니다. 컨트롤러 측면에서는 NULL입니다. – gorgonzola