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

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.69 KB  |  hits: 18  |  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. mvc3 partial view error
  2. public PartialViewResult GetStates()
  3.         {
  4.             var states = from s in conn.order_data select s.state;
  5.             return PartialView(states.ToList());
  6.         }
  7.        
  8. @model IEnumerable<bookstore.state>
  9.  
  10. @foreach (var item in Model) {
  11.  
  12.     <select>
  13.     <option>@item.STATE_Name</option>
  14.     </select>
  15. }
  16.        
  17. <div class="editor-field">
  18.     @{Html.RenderPartial("GetStates");}
  19.  </div>
  20.        
  21. public ActionMethod MainView()
  22. {
  23.   var model = new myMainModel { States = from s in conn.order_data select s.state };
  24.   return View()
  25. }
  26.        
  27. @Html.Partial("MyPartialViewName", Model.States);
  28.        
  29. if(states != null)
  30. {
  31.   return PartialView(states.ToList());
  32. }
  33.  
  34. return PartialView();