I have ViewModel and Model as below
public class MyViewModel
{
public List<MyModel> MyItems { get; set; }
/* There are many other properties*/
}
public class MyModel
{
public string MyType { get; set; }
public decimal value1 { get; set; }
public decimal value2 { get; set; }
}
I am binding the razor view as below. For column 1 I can just show the string. For columns 2 and 3 I need to show text boxes with data from the model.
<table >
<thead>
<tr>
<th>My Column1</th>
<th>My Column2</th>
<th>My Column3</th>
</tr>
</thead>
<tbody>
@foreach (var myItem in Model.MyItems)
{
<tr>
<td>
@myItem.MyType
</td>
<td>@Html.TextBoxFor( ??? )</td>
<td></td>
</tr>
}
</tbody>
</table>
In normal cases I see that we can do like @Html.TextBoxFor(m => m.myvalue1). But how to do it in the above case. Please suggest.