I've created a HTML Helper
public static IHtmlString UnorderedList<T>(this HtmlHelper helper, string listID, IEnumerable<T> items, int columns,
Func<T, HelperResult> template)
where T : class
{
if (items == null)
return new HtmlString("");
var sb = new StringBuilder();
sb.Append("<ul ");
sb.Append("id=");
sb.Append(listID);
sb.Append(">");
foreach (T item in items)
{
sb.AppendFormat("<li>{0}</li>", HttpUtility.HtmlEncode(item.ToString()));
}
sb.Append("</ul>");
return new HtmlString(sb.ToString());
}
and modified the HomePageProducts view to:
@model HomePageProductsModel
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@if (Model.Products.Count > 0)
{
<div class="list_carousel">
@(Html.UnorderedList<ProductModel>("foo0", Model.Products, 40,
//@(Html.DataList<ProductModel>(Model.Products, 3,
@<li>
@Html.Partial("_ProductSmallBox", @item)
</li>
))
</div>
}
but instead of showing the Products via the partial view _ProductSmallBox I'm now getting a LI containing "Nop.Web.Models.Catalog.ProductModel"