。什麼是這裏
錯誤您並沒有勾選相應的屬性是否不爲null,使用前:
<% foreach (Dial4Jobz.Models.CandidatePreferredLocation cl in Model.CandidatePreferredLocations) { %>
<% if (cl.Location != null) { %>
<% if (cl.Location.Country != null) { %>
<%: cl.Location.Country.Name %>
<% } %>
<% if (cl.Location.State != null) { %>
<%: cl.Location.State.Name %>
<% } %>
<% if (cl.Location.City != null) { %>
<%: cl.Location.City.Name %>
<% } %>
<% if (cl.Location.Region != null) { %>
<%: cl.Location.Region.Name %>
<% } %>
<% } %>
<% } %>
當然,爲了避免在視圖中這些檢查,你可以確保這些屬性在爲此視圖提供服務的控制器操作中正確初始化。
謝謝。它運作良好。 – PoliDev 2013-05-13 06:25:05