-1

I have a form that I want to submit to my controller, but I don't know how I should do it, I'm using MVC 5. This are the fields:

 @foreach (var item in Model)
 {
     <input type="text" name="product[@item.ProductId]" class="form-control input-number" value="0" min="0">
 }

The productId should be the key of the array item and the value of the array item should be the value of the inputbox.

J. Smith
  • 9
  • 2
  • Use the HtmlHelper methods in a `for` loop or custom `EditorTemplate` (refer [this answer](http://stackoverflow.com/questions/30094047/html-table-to-ado-net-datatable/30094943#30094943)) –  Mar 29 '16 at 21:28

1 Answers1

0

this is nasty but..

@int count=0;
@foreach (var item in Model)
 {
     <input type="text" name="product[@count++]" class="form-control input-number" value="0" min="0">
 }
Golois Mouelet
  • 307
  • 2
  • 10