Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: None  |  size: 0.81 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Using ListBoxFor for collections in collection
  2. int TerritoryId
  3. string TerritoryName
  4. List<Products> Products
  5. SelectList AllSalesReps
  6.        
  7. int ProductId
  8. string ProductName
  9. int[] SelectedSalesReps
  10.        
  11. @for(var i = 0; i < Model.Products.Count; i++)
  12.             {
  13.                     <tr valign="top">
  14.                         <td valign="top" style="vertical-align:top;">
  15.                             @Html.HiddenFor(m => m.Products[i].ProductId)
  16.                             @Html.DisplayTextFor(m => m.Product[i].ProductName)
  17.                         </td>
  18.                         <td style="padding-left:10px;">
  19.                             @Html.ListBoxFor(m => m.Products[i].SelectedSalesReps, Model.AllSalesReps, new { style = "border:solid 1px #000000;" })
  20.                         </td>
  21.                     </tr>
  22.             }