title: MVC: Displaying table data not working as expected
body: <p>I have this table in database:</p>
  
  <p><img src="https://i.stack.imgur.com/a1oGg.png" alt="enter image description here"></p>
  
  <p>I'm trying to display the the values (<code>ModuleID</code> and <code>DateEntered</code>) in the browser as table.
  I'm using viewbag to pass the value to my view, which is not quite the right way as I get just one row right now. What I'm doing right now is</p>
  
  <pre><code>public ActionResult Index()
          {
              var modules = (from entries in _db.Modules
                             orderby entries.DateEntered
                             select entries);
              ViewBag.entries = modules.ToList();
              return View();
          }
  </code></pre>
  
  <p>How can I get all rows from the table in above picture and pass it to view?
  In my view I currently have:</p>
  
  <pre><code>@using BootstrapSupport
  
      @model Sorama.DataModel.SIS.ModuleStock.Module
  
      @{
          ViewBag.Title = "Index";
          Layout = "~/Views/shared/_BootstrapLayout.basic.cshtml";
      }
  
      &lt;table class="table table-striped"&gt;
          &lt;caption&gt;&lt;/caption&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;
                     Module ID
                  &lt;/th&gt;
  
                  &lt;th&gt;
                      Date Entered
                  &lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tr&gt;
               @foreach (var entry in ViewBag.entries)
              {
                  &lt;td&gt;@entry.ModuleId&lt;/td&gt;
                   &lt;td&gt;@entry.DateEntered&lt;/td&gt;
              }
               &lt;td&gt;
                      &lt;div class="btn-group"&gt;
                          &lt;a class="btn dropdown-toggle" data-toggle="dropdown" href="#"&gt;
                              Action
                              &lt;span class="caret"&gt;&lt;/span&gt;
                          &lt;/a&gt;
                          &lt;ul class="dropdown-menu"&gt;
                                  &lt;li&gt;@Html.ActionLink("Details", "Details")&lt;/li&gt;
                                  @if (Request.IsAuthenticated &amp;&amp; HttpContext.Current.User.IsInRole("Admin"))
                                  {
                                      &lt;li class="divider"&gt;&lt;/li&gt;
                                      &lt;li&gt;@Html.ActionLink("Edit", "Edit")&lt;/li&gt;
                                      &lt;li&gt;@Html.ActionLink("Delete", "Delete")&lt;/li&gt;
                                  }
  
  
  
                          &lt;/ul&gt;
                      &lt;/div&gt;
  
                  &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
  </code></pre>
  
  <p>This shows the values of entire row and not just (<code>ModuleID</code> and <code>DateEntered</code>)
  This is what I get in browser<img src="https://i.stack.imgur.com/WZd2I.png" alt="Browser output">.</p>
  
  <p>To sum up, I want to get all the rows from table but only specific columns.
  Which is not happening at current situation. 
  Suggestions?</p>