What is the best practice for hiding a custom grid or a table or a div and display a “No Records Found” message when there are no records.
I have come up with this idea.
<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";
}
Your solution would work fine, but I think you might be overthinking it a little 🙂
This would work perfectly fine: