title: Dont understand why im getting a Null Exception when trying to fill table in MVC
body: <p>Im trying to insert data into a table on my main view from my HomeController and it is returning a null exception and I cant figure out why. </p>
  
  <p>My controller:</p>
  
  <pre><code> public ActionResult FillTable()
      {
          var MyState = new State();
  
          var StateValues1 = new State();
          StateValues1.DayTableDates = "monday";
          StateValues1.DayTableValues = "15";
          MyState.TableValuess.Add(StateValues1);
  
          return View(MyState);
      }
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code> @{
          var StateValues1 = Model.TableValuess.FirstOrDefault(); 
      }
  
      &lt;table class="greyGridTable"&gt;
  
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Date&lt;/th&gt;
                  &lt;th&gt;Value&lt;/th&gt;
  
              &lt;/tr&gt;
  
          &lt;/thead&gt;
  
          &lt;tr&gt;
              &lt;td&gt;@StateValues1.DayTableDates&lt;/td&gt;
              &lt;td&gt;@StateValues1.DayTableValues&lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
  </code></pre>
  
  <p>my Model:</p>
  
  <pre><code> public class State
  {
  
      public List&lt;State&gt; TableValuess = new List&lt;State&gt;();
  
      public string DayTableDates { get; set; }
      public string DayTableValues { get; set; }
  
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/EcnWQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EcnWQ.png" alt="null exception"></a>
  my index method: <a href="https://i.stack.imgur.com/YoPdD.png" rel="nofollow noreferrer">Index method</a>
  Im fairly new to MVC but in my head this should work. Excuse the variable names, ive been messing with it for quite a while now. 
  Thanks for the help<br>
  edit: I think the error has something to do with my view being called Index while my action method in the HomeController is called FillTable(). My index method in my controller already has code in it. How would I go about calling my FillTable method or adding my code to the Index method?</p>