title: Why won't the data in the model persist?
body: <p>I have a model, <code>MyViewModel</code>, with some members (not all are included).</p>
  
  <pre><code>namespace ANameSpace
  {
      public class MyViewModel
      {
         public int ID { get; set }
         public EditTableObject EditTable { get; set }
         public List&lt;EditTableObject&gt; EditTables { get; set }
         // some other members
      }
  
      public class EditTableObject
      {
         public int ID { get; set }
         // some other members
      }
  }
  </code></pre>
  
  <p>In the controller there are two ActionResult Index() methods</p>
  
  <p>In The first, Index(int? id), I assign a value to model.ID and also add some EditTableObjects to an EditTables list. </p>
  
  <p>Then, in the second, Index(ViewModel tmpModel), I am trying to use the members that I gave values to in the first index method. However, the ID member does not contain the value I assigned it; it's null. But strangely, the EditTables list does contain the values I assigned to it. </p>
  
  <p>Here is some code from the controller:</p>
  
  <pre><code>namespace AnotherNamespace
  {
     public class MyController
     {
        public ActionResult Index(int? id)
        {
           if (id != null)
           {
              model.ID = (int)id;
           }
           else
           {
              model.ID = 1000;
           }
  
  
           model.EditTable = new EditTableObject();
  
           model.EditTable.ID = model.ID;
  
           model.EditTables.Add(model.EditTable);
  
           return View(model);
        }
  
        public ActionResult(MyViewModel tmpModel)
        {
           return RedirectToAction("Index", new { id = tmpModel.ID });
        }
     } 
  }
  </code></pre>
  
  <p>If I set a break point on the second Index method I find that all the EditTables data persists but not the model.ID data.</p>
  
  <p>Why is the EditTables data persisting but not the model.ID data?</p>
  
  <p>Thanks for any suggestions.</p>