C# Checkbox.Checked Property Not Reflecting Check Changes
<p>I have a form with containing a datalist which is bound to a datasource which contains a list of items and a true/false flag. If true, the myCheck checkbox is checked:</p>

<pre><code>&lt;form id="myForm" runat="server"&gt;
    &lt;asp:Button ID="save" runat="server" Text="Save" OnClick="save_Click" /&gt;
    &lt;br /&gt;
    &lt;asp:DataList runat="server" id="myList" onitemdatabound="myList_ItemDataBound"&gt;
    &lt;HeaderTemplate&gt;
        &lt;th&gt;Item Name&lt;/th&gt;
        &lt;th id="thCheck" runat="server"&gt;Check?&lt;/th&gt;
    &lt;/HeaderTemplate&gt;
    &lt;ItemTemplate&gt;
        &lt;td id="tdName" runat="server"&gt;&lt;%# Eval("Name") %&gt;&lt;/td&gt;
        &lt;td runat="server"&gt;&lt;asp:CheckBox id="myCheck" runat="server" Checked="false" /&gt;&lt;/td&gt;
    &lt;/ItemTemplate&gt;
&lt;/asp:DataList&gt;
</code></pre>

<p></p>

<p>On clicking save, I want to see which items have been checked. I am using the following to iterate through the items in the datalist:</p>

<pre><code>protected void save_Click(Object sender, EventArgs e)
{
    String Name;
    Boolean omit;

    foreach (DataListItem item in myList.Items)
    {
        CheckBox omitCheck = (CheckBox)item.FindControl("myCheck");

        if (omitCheck != null)
        {
            if (omitCheck.Checked == true) // This line is my problem!!
            {
                // do stuff
            }
            break;
        }
    }
</code></pre>

<p><code>FindControl</code> appears to work ok and returns a checkbox, however the value is always false, even if I have checked some of the boxes. If I set the value of the checkboxes to True in the aspx page, <code>omitCheck.Checked</code> is always true. <code>ViewState</code> is not disabled.</p>

<p>I'm new to this so sure there is an obvious answer.</p>
