MVC ViewBag 传多个Model到视图

  • A+
所属分类:MVC

MVC ViewBag 传多个Model到视图

Controllers

  1. var sbpay= entities.SB_BASE_YEAR.Where(b => b.SB_CITY == id );    
  2.      ViewBag.sbpay = sbpay;    

Views

  1. foreach (var sbpay in ViewBag.sbpay)    
  2.       {    
  3.            <tr id="@sbpay.SB_ID_YEAR" onclick="show(this.id);">    
  4.               @{    
  5.                      if (i <= int.Parse(sbpay.SB_COM_NUM_YEAR))    
  6.                          {    
  7.                            <td>@i</td>    
  8.                             i++;    
  9.                           }    
  10.                     }    
  11.                         <td>@sbpay.SB_CALSS_YEAR</td>    
  12.                         <td>@sbpay.SB_CITY</td>                                                                     
  13.               </tr>    
  14.     
  15.                      }    
钰玺

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: