1
之前,我有这样的:检查ViewData的是空的DropDownList设置为它
<% if (ViewData["roots"] != null) {%>
<%Html.DropDownList("roots"); %>
<%}%>
但它不工作。如何检查ViewData是否存在?
之前,我有这样的:检查ViewData的是空的DropDownList设置为它
<% if (ViewData["roots"] != null) {%>
<%Html.DropDownList("roots"); %>
<%}%>
但它不工作。如何检查ViewData是否存在?
您还没有任何输出,并使用DropDownList的帮手不正确。像这样尝试:
<% if (ViewData["roots"] != null) { %>
<%= Html.DropDownList("roots") %>
<% } %>
尝试
ViewData.ContainsKey("roots")
什么不工作? – 2012-04-09 16:40:34
@amit_g ViewData [“根”]仍未定义,程序崩溃。 – user1322207 2012-04-09 16:44:22