To create some fields dynamically, I'm using a for and rendering. When calling Partial _Contact, I would like to pass the value [i] of the index of for so I can sort the fields. It's not working ... You're giving the page error ... does anyone know how to help me? A hug!
Generatingthefields:
@for(inti=0;i<Model.PessoasContatosViewModel.Count;i++){@awaitHtml.PartialAsync("_Contato", Model.PessoasContatosViewModel[i], new ViewDataDictionary { { "indice", i } })
}
Receiving the Model and Parameter in PartialView _Contact:
@model Retaguarda.Application.ViewModels.Pessoa.PessoaContatoViewModel
@{
string valuePassedIn = this.ViewData.ContainsKey("indice") ? this.ViewData["indice"].ToString() : "0";
}