-1
I need to step up my ViewBag
on my page .cshtml
, to my PartialView
in my Controller
I start her off: ViewBag.count = 0
On my page .cshtml
need to increase:
example:
@{
for (int i = 0; i < 10; i++)
{
ViewBag.count = i;
Html.Partial("EditorTemplates/Endereco", Model.Enderecos[@i]);
}
}
mine PartialView:
<div id="[email protected]"></div>
following error occurs:
O índice estava fora do intervalo. Ele deve ser não-negativo e menor que o tamanho da coleção
I guess I’d have to put @ before FOR... SOMETHING LIKE @{ for(int i = 0; i < 10; i++){ Viewbag.Count = i } }
– PauloHDSousa
@Paulohdsousa I will implement more the question, thank you for answering
– Furlan
worked what I said? @Furlan
– PauloHDSousa
@Paulohdsousa another error occurred
– Furlan
So, it turns out that within Model.Addresses[] the amount of elements is smaller than being passed in I, Another point... Pass like this -> Model.Addresses[i]);
– PauloHDSousa
uses foreach my dear!
– RBoschini
I find it much better adica from @Rboschini
– PauloHDSousa
@How would Rboschini be wearing
foreach
?– Furlan