You Define two action one for show the empty view and one for populating the view with a list :
public ViewResult Empty()
{
var products = productsRepository.Products.Where(x => x.ProductID == -1);
return View();
}
and :
public ViewResult ListAll()
{
var products = productsRepository.Products;
return View("Empty", products);
}
and in your view Empty.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<DomainModel.Entities.Product>>" %>
Empty
<h2>Empty</h2>
<table>
<tr>
<th></th>
<th>
ProductID
</th>
<th>
Name
</th>
<th>
Description
</th>
<th>
Price
</th>
<th>
Category
</th>
<th>
ImageMimeType
</th>
<th>
Error
</th>
</tr>
<% if (Model != null)
{
foreach (var item in Model)
{ %>
<tr>
<td>
<%= Html.ActionLink("Edit", "Edit", new { id = item.ProductID })%> |
<%= Html.ActionLink("Details", "Details", new { id = item.ProductID })%>
</td>
<td>
<%= Html.Encode(item.ProductID)%>
</td>
<td>
<%= Html.Encode(item.Name)%>
</td>
<td>
<%= Html.Encode(item.Description)%>
</td>
<td>
<%= Html.Encode(String.Format("{0:F}", item.Price))%>
</td>
<td>
<%= Html.Encode(item.Category)%>
</td>
<td>
<%= Html.Encode(item.ImageMimeType)%>
</td>
<td>
<%= Html.Encode(item.Error)%>
</td>
</tr>
<% }
}%>
</table>
<p>
<%= Html.ActionLink("List Products", "ListAll")%>
</p>
hope this helps