1
我想用一個ViewModel與傳遞兩個型號有一種觀點認爲
我的模型,兩個模型傳遞到一個視圖中存在的問題:
@model ProcRec.Models.PosteCandidatViewModel
<td>@Html.TextBoxFor(model => model.candidat.num_cin)</td>
<td><p>@Html.DropDownListFor(model => model.poste.Id,new
SelectList(ViewBag.Postes, "Id", "intitule_poste"),"choisir le poste")
</p></td>
m y問題是linq查詢沒有給出我想要的結果 (但是如果我給了num_cin poste.id一些值,它的工作)
所以問題是,num_cin沒有從dropdownlist的價值...這就像有一個空值!!!!!!!!!
使用我想,它給了我一個異常
ViewBag.Postes
的價值.... .............值不能爲空。參數名稱:items(DrodownList) – saidmohamed11 2014-09-10 21:51:40發生異常的位置在哪裏? – 2014-09-10 21:55:55
我修正了這個異常,這是因爲我在模型中有一個驗證.......我不想通過PosteCandidatViewModel作爲我Post操作的參數....因爲如果我這樣做,它會給我一些驗證錯誤(因爲我的模型會隱藏很多必需的屬性) – saidmohamed11 2014-09-10 22:13:00