I need to create a Partial View with MVC that will either show a List of items if more than one or an html form if only one.

Should I create a ViewModel specifically for this partial that has the following:

public Product Product { get; set; }
public IEnumerable<Product> Product { get; set; }

Or would I be better off just sending the list. If I just send the list will I be able to bind the first (and only) item to the form?

The goal is to bind the single product properties to the form if only one and if multiple loop through them and output in an html table.

Related posts

Recent Viewed