title: Change a specific column in table in ASP.NET MVC
body: <p>I am new to ASP.NET MVC. Trying to get a record from list of records in a table.  In each each record I have a field <code>status</code> which is set to be 1. Here I am showing only one record in the <code>View</code> and a <code>Button</code>. When I click on a button it has to change the status of that record to 3 in database and then get the another record in the same view. Presently I have created this view by selecting Scaffolding template List.</p>
  
  <p><strong>Controller :</strong></p>
  
  <pre><code>public class HomeController : Controller
  {
      dbSampleEntities db = new dbSampleEntities ();
      //
      // GET: /Home/
      public ActionResult Index()
      {
          var result = db.Visits.Where(x=&gt; x.Status == "1").OrderBy(r =&gt; Guid.NewGuid()).Take(1);
          return View(result);
      }
  
      [HttpPost]
      public ActionResult ChangeStatus(int VisitorID)
      {           
           return RedirectToAction("Index");         
      }
  }
  </code></pre>
  
  <p><strong>Index.html :</strong></p>
  
  <pre><code> @model IEnumerable&lt;SampleApp.Visit&gt;
  
  @{
      ViewBag.Title = "Index";
  }
  
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.VisitorID)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.FirstName)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.LastName)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Phone)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.VisitTypeID)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.BranchID)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Status)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.EmailID)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Comments)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.UserCreated)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.CreatedTime)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.UpdatedTime)
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  
      @foreach (var item in Model)
      {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.VisitorID)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.FirstName)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.LastName)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Phone)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.VisitTypeID)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.BranchID)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Status)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.EmailID)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Comments)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.UserCreated)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.CreatedTime)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.UpdatedTime)
              &lt;/td&gt;
              &lt;td&gt;
                  @using (Html.BeginForm("ChangeStatus", "Home", FormMethod.Post))
                  {
                      @Html.HiddenFor(modelItem =&gt; item.VisitorID)
                      &lt;input type="submit" value="Change Status" /&gt;
                  }
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  
  &lt;/table&gt;
  </code></pre>
  
  <p>Here <code>ChangeStatus</code> is calling but getting null values. Help me where I am mistaken.</p>