title: MVC c# List from string in ViewBag
body: <p>I am retrieving a string from a MS Sql table, it could be just one name or delimited names:  For example Tom or Speaker 1, Speaker 2.<br>
  I convert the string to list in the controller using:</p>
  
  <pre><code>                    Event cevent = db.Events.Find(id); 
                      string speakers = cevent.Speakers;     
                      ViewBag.speakers = "";
                      if (!String.IsNullOrWhiteSpace(speakers) &amp;&amp; 
                      speakers.Contains(","))
                      {
                          ViewBag.speakers = speakers.Split(',').ToList();
                      }
                      else
                      {
                          ViewBag.speakers = speakers;
                      }
                      return View(cevent);
  </code></pre>
  
  <p>In the view I use the following to display the list:</p>
  
  <pre><code>         &lt;ul&gt;
              @foreach (var item in ViewBag.speakers)
              {
                  &lt;li&gt; @item &lt;/li&gt;
              }
          &lt;/ul&gt;
  </code></pre>
  
  <p>Works great with the list, I get:</p>
  
  <pre><code>• Speaker 1
  • Speaker 2
  </code></pre>
  
  <p>However, if the ViewBag has just one item, I get:</p>
  
  <pre><code>• T 
  • o 
  • m 
  </code></pre>