title: Razor DropDownList
body: <p>i want to add a dropdoenlist for months. i want select value like january/february.. i've created a action like this:</p>
  
  <pre><code>     public DropDownList  GetMyMonthList()
       {
          DropDownList MyddlMonthList = new DropDownList();
          DateTime month = Convert.ToDateTime("1/1/2000");
          for (int i = 0; i &lt; 12; i++)
          {
  
              DateTime NextMont = month.AddMonths(i);
              ListItem list = new ListItem();
              list.Text = NextMont.ToString("MMMM");
              list.Value = NextMont.Month.ToString();
              MyddlMonthList.Items.Add(list);
          }
          return MyddlMonthList;
  
      }
  </code></pre>
  
  <p>and i called it </p>
  
  <pre><code>  ViewBag.months = pm.GetMyMonthList();
  </code></pre>
  
  <p>in my View</p>
  
  <pre><code>  @Html.DropDownListFor(model =&gt; model.rent_month,new    SelectList(ViewBag.months          as        System.Collections.IEnumerable, "Text","value"),
          "Select Month")
  </code></pre>
  
  <p>it gives error <strong>Value cannot be null.
  Parameter name: items</strong> <p>i'm may be doing a silly mistake. i'm very new in asp.net mvc3. please indicate me my mistake.... thanks in advance </p></p>