2014-07-09 3 views
0

나는 이러한 두 가지 방법을 호출하는 검도 그리드가 있습니다.두 번째로 호출 할 때 모델의 값이 손실 됨

public ActionResult DepthDefinition_Read([DataSourceRequest] DataSourceRequest request, int wellId) 
{ 
    var list = _service.FindBy(x => x.WellId == wellId); 

    return Json(list.ToDataSourceResult(request)); 
} 

[AcceptVerbs(HttpVerbs.Post)] 
public ActionResult DepthDefinition_Create([DataSourceRequest] DataSourceRequest request, DepthDefinition depthDefinition, int wellId) 
{ 
    if (depthDefinition != null && ModelState.IsValid) 
    { 
     depthDefinition = _service.Insert(depthDefinition); 
    } 
    return Json(new[] { depthDefinition }.ToDataSourceResult(request, ModelState)); 
} 

이제 호출 정의는 다음과 같습니다

.Read(read => read.Action("DepthDefinition_Read", "DepthDefinition", 
     new RouteValueDictionary(new Dictionary<string, object>() { { "wellId", Model } }))) 
    .Create(update => update.Action("DepthDefinition_Create", "DepthDefinition", 
     new RouteValueDictionary(new Dictionary<string, object>() { { "wellId", Model } }))) 

을 그리고 내가 그리드와 함께 내 시야를로드 할 때, 나는 이런 식으로 작업을 수행합니다

public ActionResult Index(int wellId) 
{ 
    return PartialView("DepthDefinition", wellId); 
} 

읽기 방법은 wellId을 얻고 그것의 가치는 1이다. 모두는 감미롭고 멋쟁이 다. 그런 다음 새 행을 만들고 버튼을 클릭하고 값을 입력 한 다음 저장을 클릭합니다. 이제 어떻게 되나요? 제가 전달하려고 시도하는 wellId이 마술처럼 바뀌었고 이제는 0입니다. 세상에서 어떻게 그런 일이 일어 났습니까? 내 모델이 가치를 잃는가?

첫 번째 통화에서 두 번째 통화로의 가치를 잊어 버린 이유를 누가 알 수 있습니까?

+0

확실하지 않음을하지만 부분보기에 숨겨진 필드를 넣어보십시오. @ Html.Hidden ("wellId", 1) –

+0

할 수는 있지만 모델을 사용하는 전체 개념을 무시할 것입니다. 그렇지 않습니까? - 그리드에 어떻게 삽입 할 것인가? –

+0

일치하는 formattribute가 발견되지 않으면 int 값이 0으로 간주됩니다. 디버깅을 쉽게하려면 WellId를 int로 변경하십시오. 선체인지 확인하십시오. 그렇다면, 어떻게 든 당신의 견해에서 길을 잃었습니다. –

답변

관련 문제