I have a view that allows the user to inset multiple elements of the same type.
@foreach (var gm in Model)
{
<tr><td>
@Html.TextBoxFor(model => gm.name)
</tr></td>
}
But, when I saw the generated HTML it is duplicating the id and the name
<tr><td>
<input id="gm_name" name="gm.name" type="text" value="" />
</td></tr>
<tr><td>
<input id="gm_name" name="gm.name" type="text" value="" />
</td></tr>
Is there a way to automatically add an 1,2,3,etc and the end of id, example:
<tr><td>
<input id="gm_name1" name="gm.name1" type="text" value="" />
</td></tr>
<tr><td>
<input id="gm_name2" name="gm.name2" type="text" value="" />
</td></tr>
I can do that if I generate all the html, but, is there an automatically way to achieve that?
Thanks