title: Storing an List<int> in viewstate
body: <p>I have an aspx page which has the following:</p>
  
  <ul>
  <li>A repeater with a linkbutton in each </li>
  <li>The link button has a commandargument of an integer value</li>
  <li>A user control</li>
  </ul>
  
  <p>The idea is that when the user clicks on the linkbutton the value of the commandarguement is stored in a List. No problem you may think, however I need the value to be stored in an List in the usercontrol, not in the ASPX page. The List needs to be persisted across postbacks, so it also needs to be stored in the viewstate.</p>
  
  <p>So I created a public property in the user control like so:</p>
  
  <pre><code>public List&lt;int&gt; ImageString {
      get {
          if (this.ViewState["ImageString"] != null) {
              return (List&lt;int&gt;)(this.ViewState["ImageString"]);
          }
          return new List&lt;int&gt;();
      }
      set { this.ViewState["ImageString"] = value; }
  }
  </code></pre>
  
  <p>And then I was hoping that from my aspx page I could add a line of code to add a value to the list like so:</p>
  
  <pre><code>this.LightBoxControl.ImageString.Add(value);
  </code></pre>
  
  <p>The problem I'm getting is that the the value is actually never added to the list. The count  is always zero.</p>
  
  <p>I'm sure its just that I've set the property up wrong, but I'm not sure how to right it..</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks
  Al</p>