-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.

1
  • Use the HtmlHelper methods in a for loop or custom EditorTemplate (refer this answer) Commented Mar 29, 2016 at 21:28

1 Answer 1

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">
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.