I have a FeedbackViewModel that contains a list of questions:
public class FeedbackViewModel
{
public List Questions { get; set;
Using Razor you can implement the for loop using a dictionary as follows without making changes to your object:
@foreach (var x in Model.Questions.Select((value,i)=>new { i, value }))
{
if (Model.Questions[x.i].QuestionType == "Single")
{
@Html.EditorFor(modelItem => (modelItem.Questions[x.i] as OpenDataPortal.ViewModels.SingleQuestionViewModel).AnswerText)
}
...
}
The collection needs to be either a List or Array for this to work.