title: ASP.NET mvc : populate (bind data) in listbox
body: <p>I need to populate two listboxes with data from a database.
  But I need to display two listboxes in one view, so I created a ListBoxModel class.</p>
  
  <pre><code>public class ListboxModel
  {
      public ListBox LB1 { get; set; }
      public ListBox LB2 { get; set; }
  }
  </code></pre>
  
  <p>And in my Controller:</p>
  
  <pre><code>public ActionResult IndexStudents(Docent docent, int lessonid, int classid)
      {
          var MyListBox = new ListboxModel
          {
              LB1 = new ListBox(docent.ReturnStudentsNormal(lessonid, classid),
              LB2 = new ListBox(docent.ReturnStudentsNoClass(lessonid, classid)
          };
          return View(MyListBox);
      }
  </code></pre>
  
  <p>But this code does not work, how can I bind the data to the listboxes?
  So I'd like to use 2 models, one for each listbox... one with normal students and one with students who are not subscribed for lessons.
  How could I do that?
  And what code do I have to write in my view?
  Something like:</p>
  
  <pre><code>&lt;div class="editor-field"&gt;
       &lt;%: Html.ListBox("IndexStudentsNormal", Model.LB1) %&gt; 
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;div class="editor-field"&gt;
        &lt;%: Html.ListBox("IndexStudentsNoClass", Model.LB2) %&gt; 
  </code></pre>
  
  <p></p>
  
  <p>The listbox has to be a listbox with multiple colums so that it can contain the name, sirname, class, teacher of the student.</p>
  
  <p>Student is an object, I'd like to display student.Name, student.Sirname, student.Class, and so on in that listbox.</p>
  
  <p>So can I use an object in a ListBox, or do I have to convert everything to strings?</p>
  
  <p>How can I do that? </p>
  
  <p>Thanks in advance!</p>