title: how to pass my viewbag content (a huge table) from view to controller, in ASP.NET MVC 5
body: <p>I am less experience and developing a portal, using ASP.NET MVC 5. After getting user request from portal, backend database query happened, and the data is display as a table in portal. If user want to save the table, user can click SAVE button to save it to user local computer.  Therefore, I need to send it as ViewBag.tables, and then store this table in local windows storage. When user press SAVE button, I can get this table back to controller, put it in excel, then transmit it to user for saving.</p>
  
  <p>However, I am not able to send back the table from View, in <code>List&lt;List&lt;string&gt;&gt;</code> form,  to controller.  Please help me.  Thank you for your great effort.</p>
  
  <p>//---------------------------------------------------------------------</p>
  
  <p>From the controller, I put this table ( is a <code>List&lt;list&lt;string&gt;&gt;</code> ) into <code>ViewBag.tables</code> :</p>
  
  <pre><code>public ActionResult TestPage()
  {
     ViewBag.tables = GlobalVariables.tableSend2View;
     return View();
  }
  </code></pre>
  
  <p>//---------------------------------------------------------------------</p>
  
  <p>Then, in view, javescript, it is store in windows storage, get from the storage,
  filled in the Html Helper (Html.TextAreaFor), this value is ready to send to controller when user click SAVE button:</p>
  
  <pre><code>&lt;script&gt;
  var storeTable = window['localStorage'];
  storeTable.setItem("postBackTab", postBackTable);
  var getJustAfterStore = storeTable.getItem("postBackTab");
  var postBackFunc = document.getElementById("TB_ReturnTable_ID");
  postBackFunc.value = getJustAfterStore;
  &lt;/script&gt;
  </code></pre>
  
  <p>//---------------------------------------------------------------------</p>
  
  <p>in View, when the Save button is click :</p>
  
  <pre><code>@using (Html.BeginForm("SaveResult", "Management"))
  {
      @Html.TextAreaFor(m =&gt; m.postBacLis.POSTBACKLIST, new { @class = "form-control", style = "display: none;", id = "TB_ReturnTable_ID", name = "TB_ReturnTable_NAM" });
      &lt;button type="Submit" class="btn-lg btn-info" , id="postBackButton"&gt;Save Result&lt;/button&gt;
  }
  </code></pre>
  
  <p>//---------------------------------------------------------------------</p>
  
  <p><code>m.postBacLis.POSTBACKLIST</code>, a variable of type <code>List&lt;List&lt;string&gt;&gt;</code>, is define in Model class:</p>
  
  <pre><code>private List&lt;List&lt;string&gt;&gt; _postBackList;
  public List&lt;List&lt;string&gt;&gt; POSTBACKLIST
  {
     get { return _postBackList; }
     set { _postBackList = value; }
  }
  </code></pre>
  
  <p>//---------------------------------------------------------------------</p>
  
  <p>However, I am not able to get value from my controller:</p>
  
  <pre><code>public ActionResult SaveResult(ManagementViewModel getPostBackTable)
  {
     return View();
  }
  </code></pre>
  
  <p>//---------------------------------------------------------------------</p>
  
  <p>When I put a break point in return View();  , as in above,
  from watch, getPostBackTable....., I get the following :</p>
  
  <pre><code>+ POSTBACKLIST  Count = 0  System.Collections.Generic.List&lt;System.Collections.Generic.List&lt;string&gt;&gt;
  </code></pre>
  
  <p>I am not able to get anything send back from view.</p>
  
  <p>Please help.
  Your effort is very much appreciated.</p>
  
  <p>Thank you.</p>
  
  <p>Cheers,
  NewBuntu</p>