title: unable to show name on each entry asp.net mvc
body: <p>I'm having an issue when I select an employee name; the last name that was selected it is what is shown on the view but I would like the employee name to be change. Say for example I enter Trev and I click add, add another name Trudan; it should show all the names and not only Trudan. I suspect it is because of the for loop.</p>
  
  <pre><code>&lt;table id=" myTable" &gt;
          &lt;tr&gt;
              &lt;th&gt;@Html.CheckBox("TheOneCheckBoxToRuleThemAll")&lt;/th&gt;
  
             &lt;th class="col-lg-3"&gt;Requisition Number&lt;/th&gt;
          &lt;th class="col-lg-3 "&gt;Employee&lt;/th&gt;
              &lt;th class="col-lg-3 "&gt;Expense Account&lt;/th&gt;
              &lt;th class="col-lg-3 "&gt;Description&lt;/th&gt;
              &lt;th class="col-lg-3 "&gt;Item Number&lt;/th&gt;
              &lt;th class="col-lg-3 "&gt;Quantity&lt;/th&gt;
              &lt;th class="col-lg-3 "&gt;Requisition Date&lt;/th&gt;
  
          &lt;/tr&gt;
  
  
        @{
  
            if (@Model.items.Count &gt; 0)
            {
  
                foreach (var item in Model.items)
                {
  
                  &lt;tr&gt;
                      &lt;td&gt;@Html.CheckBoxFor(m =&gt; m.postTrnx, new { @class = "checkGroup1" })&lt;/td&gt;
  
                     &lt;td class="label"&gt;@Html.DisplayFor(m =&gt; m.reqNumber) &lt;/td&gt;
                      &lt;td class="col-lg-3 tabledata"&gt;@Html.DisplayFor(model =&gt; model.employeeDetails.getName)&lt;/td&gt;
                      &lt;td class="col-lg-3 tabledata"&gt;@item.expense_account.getDescription&lt;/td&gt;
                      &lt;td class="col-lg-3 tabledata"&gt;@item.description&lt;/td&gt;
                      &lt;td class="col-lg-3 tabledata"&gt;@item.itemNumber&lt;/td&gt;
                      &lt;td class="col-sm-1 tabledata"&gt;@item.quantity&lt;/td&gt;
                      &lt;td class="label"&gt;@Html.DisplayFor(m =&gt; m.reqDate)&lt;/td&gt;   
                  &lt;/tr&gt;
  
                    }
                }
            }
  
      &lt;/table&gt;
  
     [ActionName("RequisitionItem")]
      [HttpPost]
      [AcceptVerbs(HttpVerbs.Post)]
      [AcceptParameter(Name = "Add", Value = "Add")]
      public ActionResult AddItems(Requisition requisition, string expense_desc)
      {
          IssueDAO issuedb = new IssueDAO();
          ViewBag.StoresReps = issuedb.SelectEmployeesByDept("Stores");
          ViewBag.ReceivedByReps = issuedb.SelectEmployeesByDept(requisition.department);
          //getIssue.docNumber = issue.docNumber;
          //getIssue.docType = "Issue";
          getRequisition.department = requisition.department;
          getRequisition.employeeDetails.employeeNum = requisition.employeeDetails.employeeNum;
          //getRequisition.processedbyDetails.employeeNum = issue.processedbyDetails.employeeNum;
          //getIssue.expense_acccount = issue.expense_acccount;
          //getRequisition.expense_account = requisition.expense_account;
          getRequisition.reqDate = DateTime.Now;
          getRequisition.reqNumber = getRequisition.reqNumber;
          //Check to see if item is already exist on the current Issue
          for (int i = 0; i &lt; getRequisition.items.Count; i++)
          {
              if (getRequisition.items[i].itemNumber == requisition.item.itemNumber)
              {
                  ViewBag.errorMessage = "Item already exists";
                  return View(getRequisition);
              }
  
  
  
          }
          //Check that the user only enters one item per request
          //if (getRequisition.items.Count &gt;= 1)
          //{
          //    ViewBag.errorMessage = "Error, Only one item per request "; 
          //    return View(getRequisition);
          //}
          //Item validation Section
          if (items.Count == 0)
          {
              itemtbl.connectionString = ConfigurationManager.ConnectionStrings["TWCL_OPERATIONSConnectionString"].ConnectionString;
              try
              {
                  items = itemtbl.getItems();//Gets items from database
              }
              catch (Exception ex)
              {
                  LogWrite logWriter = new LogWrite(ex.ToString());
                  ViewBag.errorMessage = "Unable to Connect to Database. Please see Log file for more Information";
                  return View(getRequisition);
              }
  
          }
  
          foreach (var item in items)
          {
              //Checks to see if item is in the database by searching for the item
              if (requisition.item.description == item.description)
              {
                  //Checks to see if the item number specified matches that specified for the item
                  if (requisition.item.itemNumber == item.itemNumber)
                  {
  
                      requisition.item.lineNum = getRequisition.items.Count + 1;//Sets the line number to the index of the item plus one so has to have the Line number begin at 1
                      requisition.item.expense_account.account_desc = expense_desc;
                      string acc_desc = Regex.Replace(requisition.item.description, @"[^a-zA-Z0-9ęąół]", " ");
                      requisition.item.description = acc_desc;
                      getRequisition.addItems(requisition.item);
                      //getIssue.processedbyDetails.employeeNum = issue.processedbyDetails.employeeNum;
                      getRequisition.reqNumber = requisition.reqNumber;
  
  
                      //Reset the item varaible of the model to empty so as to accept new values
                      ModelState["item.itemNumber"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                      ModelState["item.description"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                      //ModelState["item.price"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                      ModelState["item.quantity"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                      return View(getRequisition);
                  }
                  ModelState["item.itemNumber"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                  ModelState["item.description"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                  //ModelState["item.price"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                  ModelState["item.quantity"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
                  ViewBag.errorMessage = "The Item Number and Description do not match";
                  return View(getRequisition);
              }
          }
              ModelState["item.itemNumber"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
              ModelState["item.description"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
              //ModelState["item.price"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
              ModelState["item.quantity"].Value = new ValueProviderResult("", "", CultureInfo.CurrentCulture);
              ViewBag.errorMessage = "Invalid Item Description";
              return View(getRequisition);
  
      }
  </code></pre>