Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 466.7k

Dropdownlistfor On your View return null, how to fix it?

Sep 7 2020 3:16 AM
Hi Team
 
I need some help, i want to create list of values using dropdownlist for, now on the view i am getting a null object when accessing them.
  1. @using (Html.BeginForm("SuperAdmin""Home", FormMethod.Post))    
  2. {    
  3.     <div class="form-group row">    
  4.         <label for="Content-Licence" class="col-sm-3 col-form-label">Content Licence</label>    
  5.         <div class="col-sm-5">    
  6.         @Html.DropDownListFor(model => model.Dashboard.CourseLicence, new SelectList(Model.lsteNtsaDashboard))    
  7.         </div>    
  8.     </div>    
  9. }   
  1. public ActionResult SuperAdmin() {    
  2.     
  3. var list = new List<string>() { "Private(Copyrighted)""Public Domain""Creative Commons Licences""CC Attribution""CC Attribution Share ALike""CC Attribution Non-Commercial",     
  4.                 "CC Attribution Non-Commercial Share Alike""CC Attribution Non Directive""CC Attribution Non-Commercial No Directives" };    
  5.             ViewBag.list = list;    
  6.     
  7. return View(list);    

  8. }    
  9.     
  10. public class eNtsaDashboardViewModel    
  11. {    
  12.         public string CourseName { getset; }      
  13.         public List<eNtsaCourses> CourseLicence { getset; }    
  14.     
  15. }    
 

Answers (2)