2011-08-03 82 views
0

如何在我的視圖中顯示foolowing?在mvc中顯示陣列數組

我有一個類,如下所示:

public class testArrays() 
{ public list<int>ID{get;set;} 
public int TotalAccount{get;set;} 
public List<int> Account{get;set;} 
} 
public List<testArrays> test {get;set;} 

How can I displat the values of test in my view? Part of my code is as follows: 
foreach(var i in model.test) 
{ 
foreach(var j in i)<-----stuck as from here 
{ 

} 

}

回答

2

你做任何嵌套循環一樣。除非我錯過了什麼?

foreach(var i in model.test) // i is "testArrays" 
{ 
    foreach(var x in i.ID) // x is "int" 
    { 
     // .. 
    } 
} 

更好的方法是使用自定義顯示模板。