Checking and unchecking checkboxes after postback in Page_PreRender
<p>I have a dynamic table that's in a update panel. The data of the table gets filled form the code behind. In every row there is a checkbox. After a postback the checkboxes get rechecked if they need to be checked. I have all the items that needs to be chacked in a list. This list gets checked in the PreRenderer. This works fine if the page opens for the first time.</p>

<pre><code>void Page_PreRender(object sender, EventArgs e)
        {
            foreach (string CheckedeID in cboCheckedList)
            {
                CheckBox checkedBox = (CheckBox)tbl_main.FindControl(CheckedeID);
                checkedBox.Checked = true;
            }
        }
</code></pre>

<p>After a postback, if a button gets click to change the checked status. The new ID gets added to the cboCheckedList. I can see when I'm debugging the item is in the list and the new item also gets checked. But when I return to the page the checkbox isn't checked.</p>

<p>Am I setting the checkbox in the wrong location? 
Where should I set the checkbox so it will stay checked?</p>

<p>The code of the table in the updatepanel:</p>

<pre><code>&lt;asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional"&gt;
        &lt;ContentTemplate&gt;
            &lt;asp:Table runat="server" ID="Table1" BorderStyle="Solid" BorderWidth="2" GridLines="Both" BackColor="White" class="tablesorter"&gt;
                &lt;asp:TableHeaderRow ID="TableHeaderRow2" runat="server"&gt;
                    &lt;asp:TableHeaderCell BackColor="#CEE3F6" ForeColor="White" Wrap="false" Width="50px"
                        HorizontalAlign="Center" CssClass="NoImage"&gt;
                    &lt;/asp:TableHeaderCell&gt;
                    ....
                &lt;/asp:TableHeaderRow&gt;
            &lt;/asp:Table&gt;
        &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
</code></pre>
