隐藏自定义网格、表格或 div 并在没有记录时显示“未找到记录”消息的最佳做法是什么。
这个想法是我想出来的。
<div class="<%= Html.IsVisible(Model.Count)">
...
..
..
</div>
.displayNone {display:none;} .displayInherit {display:inherit;}
public static string IsVisible(this HtmlHelper helper,int recordCount)
{
return recordCount == 0 ? "displayNone" : "displayInherit";
}
最佳答案
你的解决方案可以正常工作,但我认为你可能想得太多了:)
这会工作得很好:
<% if (Model.Count == 0) { %>
No Records Found
<% } else { %>
// do something to show the Model information here
<% }
关于asp.net-mvc - 在 ASP.NET MVC 中隐藏表格或网格并显示 "No records found"消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2077233/