I'm using ASP.NET MVC 4 and LINQ/SQL. I have an HTML page with a form where I want to render HTML input boxes based on a Model Class. In my view, I'm looping over the model and trying to generate an input box for each table row, but since the model is empty, the input boxes do not show. The model is empty because there is no data in the database yet as that is what I want to collect in my form. When there is data in the model, the values from the database should show in the form.
How can I render the empty input boxes, given that my model is initially empty.
Code is below:
@for (int i = 0; i < Model.Count; i++)
{
<tr>
<td>
@Html.EditorFor(model => model[i].CustomerName, new { htmlAttributes = new { @class = "form-control" } })
</td>
</tr>
}