3
I did it just as a test:
@model Operador.MVC.Models.OperadorModel
@{
ViewBag.Title = "Operador";
}
<table id="tblOperador" class="table table-hover table-striped" border="1" cellspacing="0" style="width: 100%;">
<thead>
<tr>
<th>Code</th>
<th>NameHealth</th>
<th>NameDental</th>
<th>LastUpdateDate</th>
<th>LastUpdateLogin</th>
<th>Brand Code</th>
<th>Brand</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.NameHealth)
</td>
<td>
@Html.TextBoxFor(modelItem => item.NameDental, new { style = "width: 50px;"})
</td>
</tr>
}
</tbody>
When I rethink it gives me that mistake:
Server Error in Application '/'.
Build Error
Description: Error when compiling a resource needed to meet this request. Examine the specific details of the error and modify the source code appropriately.
Compiler Error Message: CS1579: Foreach Instruction Cannot operate on variables of type 'Operator.MVC.Models.Operadormodel' because 'Operator.MVC.Models.Operadormodel' does not contain a public definition to 'Getenumerator'
Error of Origin:
Line 20: Line 21: Line 22: @foreach (var item in Model) Line 23: { Line 24:
Archive of Origin: c: Projects_mvc Operator.MVC Views Operator Operator.cshtml Line: 22
Show Compiler Detailed Output:
Show Full Build Source:
Version Information: Microsoft . NET Framework Version:4.0.30319; Version of ASP.NET:4.0.30319.34249
How do I solve the Getenumerator problem? What should I add?
I get it, just to confirm. If I have a class, say Operadormodelteste and in it I have a method that returns me a list of operators and if I put like this: @model Operator.MVC.Models.Operadormodelteste, so I can make a foreach and fill the TD’s of my table?
– pnet
No. You have to use the method that returns a list.
– Jéf Bueno
But how do I do it? I don’t understand, I’m sorry for my ignorance, but I don’t understand how I do it.
– pnet