0
I am trying to access the elements of a list stored in Viewbag as follows:
function equipamentoTemControle() {
for(i = 0; i < @ViewBag.qtdEquipamentos; i++) {
var contratocod = @ViewBag.DadosEquipamentos[i].contratocod;
}
}
But when trying to access the attribute contratocod of the Indian i Visual Studio says that the variable i does not exist. How should I access ?
Shouldn’t be
qtdEquipamentos[i].contratocod;
instead ofDadosEquipamentos[i].contratocod;
?– Sergio
No, because Viewbag.qtdEquipments is an integer, and Viewbag.Data Equipment is the list I want to access.
– Raphael Prado de Oliveira
But the array is
qtdEquipamentos
right? in that case maybeqtdEquipamentos[i].DadosEquipamentos.contratocod
?– Sergio
No. qtdEquipments is only an integer. The array is Dataequipments
– Raphael Prado de Oliveira
What gives
alert(typeof @ViewBag.DadosEquipamentos);
?– Sergio
System.Collections.Generic.List`1[SCO.Models.Equipmentsmodel]
– Raphael Prado de Oliveira