Keep generic list values after postback error
<p>I'm getting "Type 'ViewStateTest._Default+sInfo' in Assembly... is not marked as serializable" error when trying to keep generic list values after postback, what am I doing wrong here?</p>

<p>code:</p>

<pre><code>public partial class _Default : System.Web.UI.Page
{
    List&lt;sInfo&gt; InfoList1 = new List&lt;sInfo&gt;();
    sInfo Info1;
    struct sInfo
    {
        public int LSR;
        public string BrandAcc;
        public string CreateDate;
        public string QName;
    }

    private void CreateArray()
    {
        Info1.LSR = 2;
        Info1.BrandAcc = "AA";
        Info1.CreateDate = "12/12/2011";
        Info1.QName = "Completed";
        InfoList1.Add(Info1);
    }       

    protected void Page_Load(object sender, EventArgs e)
    {
        if (ViewState["arrayListInViewState"] != null)
        {
            InfoList1 = (List&lt;sInfo&gt;)ViewState["arrayListInViewState"];                
        }
        else
        {
            // ArrayList isn't in view state, so we need to load it from scratch.
            CreateArray();
        }
        // Code that uses PageArrayList.
        Label1.Text = InfoList1[0].LSR.ToString();
        Label2.Text = InfoList1[0].BrandAcc;
        Label3.Text = InfoList1[0].CreateDate;
        Label4.Text = InfoList1[0].QName;
    }

    void Page_PreRender(object sender, EventArgs e)
    {
        // Save PageArrayList before the page is rendered.
        ViewState.Add("arrayListInViewState", InfoList1);
    }

    protected void Timer1_Tick(object sender, EventArgs e)
    {

    }
</code></pre>

<p>html code:</p>

<pre><code>&lt;body&gt;
&lt;form id="form1" runat="server"&gt;
&lt;div&gt;
    &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;&lt;/asp:ScriptManager&gt;
    &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt;
        &lt;ContentTemplate&gt;
            &lt;asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick"&gt;&lt;/asp:Timer&gt;
            &lt;asp:HiddenField ID="hfTableTopInfoCount" runat="server" Value="0" /&gt;
            &lt;div id="Container"&gt;                            
               &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
                &lt;br /&gt;
                &lt;asp:Label ID="Label2" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
                &lt;br /&gt;
                &lt;asp:Label ID="Label3" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
                &lt;br /&gt;
                &lt;asp:Label ID="Label4" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;                 
            &lt;/div&gt;
        &lt;/ContentTemplate&gt;                    
    &lt;/asp:UpdatePanel&gt;
&lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p></p>
