0

I have a model that have list properties.

public class Class01 
{
  List<string> PropA {get; set;}
  List<string> PropB {get; set;}
}

now in my view, i want to create @Html.TextBoxFor for each of the item in each of the list. i am not good with lamba expressions and so cant figureout how to provide a valid lambda expression for the above requirement.

Note : i dont want to prefer the following way :

@Html.TextBoxFor(m => m.PropA[0])

I want to loop through all properties and then nested loop through each items for creating textboxes.

please help me. Thank you.

alexbt
  • 16,415
  • 6
  • 78
  • 87
  • You need a `for` loop or `EditorTemplate` - refer [this answer](http://stackoverflow.com/questions/30094047/html-table-to-ado-net-datatable/30094943#30094943) –  Sep 14 '16 at 22:57

1 Answers1

0

Use @foreach :

 @foreach (Propa p in model.PropA ) {
}
Hadee
  • 1,392
  • 1
  • 14
  • 25
  • Hi.... Thanks for reply.. :) Actually i would like to prefer a bit different solution. there are almost 50 list properties. i dont want to hard code all those loops. i would rather like to loop through all properties, and into that loop, some lambda expressions that could create textboxes for all string items in all lists. – Chintan Rotliwala Sep 16 '16 at 07:14