2010-09-07 4 views
0

ModèleLiez une liste avec la liste imbriquée

public class PdfPage 
{ 
    public IEnumerable<PdfPhoto> Photos { get; set; } 
} 

public class PdfPhoto 
{ 
    public string path { get; set; } 
} 

Voir

<ul> 
    <li> 
    <%= Html.Hidden("ListPages[0].Photos[0].path", "/public/pdfMaker/4_e.jpg")%> 
    <%= Html.Hidden("ListPages[0].Photos[1].path", "/public/pdfMaker/4_f.jpg")%> 
    <%= Html.Hidden("ListPages[0].Photos[2].path", "/public/pdfMaker/13_p.jpg")%> 
    </li> 
    <li> 
    <%= Html.Hidden("ListPages[1].Photos[0].path", "/public/pdfMaker/5_f.jpg")%> 
    <%= Html.Hidden("ListPages[1].Photos[1].path", "/public/pdfMaker/7_f.jpg")%> 
    <%= Html.Hidden("ListPages[1].Photos[2].path", "/public/pdfMaker/8_e.jpg")%> 
    <%= Html.Hidden("ListPages[1].Photos[3].path", "/public/pdfMaker/8_f.jpg")%> 
    </li> 
    <li> 
    <%= Html.Hidden("ListPages[2].Photos[0].path", "/public/pdfMaker/11_e.jpg")%> 
    </li> 
</ul> 

Contrôleur

public ActionResult Create(List<PaginaPdf> ListPages) 
{ 
    string list = string.Empty; 

    foreach (var page in ListPages) 
    foreach(var photo in page.Photos) 
     list += "photo: " + photo .path + "\r\n"; 

    return new ContentResult 
    { 
    Content = list 
    }; 
} 

mais ne fonctionne pas.
Est-ce que quelqu'un sait comment lier une liste imbriquée dans MVC 2?

Répondre

0

Désolé, cela fonctionne.
Un "s" me manque dans View. Mon erreur.

Questions connexes