title: Binding dropdownlist asp.net mvc
body: <p>I've populated a dropdownlist with data from my database. However, I'm unsure if my method is effective or not. What can I do to improve this or is the method I used secure/sufficient?</p>
  
  <p>I have added the controller, the viewModel and the View below. All advice is greatly appreciated!</p>
  
  <p>Controller:</p>
  
  <pre><code> [HttpGet]
      public ActionResult SchedulerIndex()
      {
          Entities entities = new Entities();
  
          var getJobList = entities.Jobs.ToList();
          SelectList list = new SelectList(getJobList, "JobId", "JobName");
          ViewBag.jobListName = list;
  
  
      [HttpPost]
      public ActionResult ScheduleInfo(Values model, int JobList1, string Second, string Minute, string Hour, object DayOfMonth, object Month, object DaysOfWeek, int repeatTime)
      {
          model.Job = JobList1;
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>    @using (Html.BeginForm("ScheduleInfo", "Scheduler", FormMethod.Post))
  {
      Html.EnableClientValidation();
  &lt;center&gt;
      &lt;div style="text-align: center"&gt;
          &lt;div class="form-group"&gt;
              &lt;h4&gt;Select a job from the list&lt;/h4&gt;
              @Html.DropDownList("JobList1", ViewBag.jobListName as SelectList)
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/center&gt;
  </code></pre>
  
  <p>ViewModel:</p>
  
  <pre><code>    public class Values
  {
  
      public List&lt;object&gt; DayOfMonth { get; set; }
      public List&lt;object&gt; Month { get; set; }
      public List&lt;object&gt; DaysOfWeek { get; set; }
  
  
  
      [Required(ErrorMessage = "Enter a number between 0-59!")]
      [RegularExpression(@"^(,{0,1}(\b\d\b|[0-5][0-9]|\*+)(-\b\d\b|-[0-5][0-9]){0,1})$", ErrorMessage = "Enter a number between 0-59!")]
      public object Second { get; set; }
  
  
      [Required(ErrorMessage = "Enter a number between 0-59!")]
      [RegularExpression(@"^(,{0,1}(\b\d\b|[0-5][0-9]|\*+)(-\b\d\b|-[0-5][0-9]){0,1})$", ErrorMessage = "Enter a number between 0-59!")]
      public object Minute { get; set; }
  
  
      [Required(ErrorMessage = "Enter a number between 0-23!")]
      [RegularExpression(@"^(,{0,1}(\b\d\b|[0-1][0-9]|[2][0-3]|\*+)(-\b\d\b|-[0-1][0-9]|-[2][0-4]){0,1})$", ErrorMessage = "Enter a number between 0-23!")]
      public object Hour { get; set; }
  
  
      //public List&lt;SelectListItem&gt; Jobs { get; set; }
      public int Job { get; set; }
  
      public List&lt;Values&gt; DofMInfo { get; set; }
      public string DofMNo { get; set; }
      public int DofMID { get; set; }
  
      public List&lt;Values&gt; MonthInfo { get; set; }
      public int monthID { get; set; }
      public string monthName { get; set; }
  
  
      public List&lt;Values&gt; DayInfo { get; set; }
      public int dayID { get; set; }
      public string dayName { get; set; }
  
      [Required(ErrorMessage ="Enter the number of repeat times. 0 = execute once!")]
      public int repeatTime { get; set; }
  
      public bool IsChecked { get; set; }
  }
  </code></pre>