Checkbox type conversion
<p>I am using Visual studio 2010 with C#.</p>

<p>I have a problem, on one of my ascx pages I created a checkbox column like this:</p>

<pre><code>&lt;asp:TemplateField ItemStyle-HorizontalAlign="left" HeaderStyle-HorizontalAlign="Left" HeaderText="Beetald"&gt;
    &lt;HeaderTemplate&gt;
        &lt;input type="checkbox" id="selectallTeachers" class="selectallTeachers" onclick="javasctipt:SelectheaderCheckboxesTeacher();" /&gt;
    &lt;/HeaderTemplate&gt;
    &lt;ItemTemplate&gt;
        &lt;input type="checkbox" id="chkPaid" class="caseTeacher" name="caseTeacher" runat="server" /&gt;
    &lt;/ItemTemplate&gt;
&lt;/asp:TemplateField&gt;
</code></pre>

<p>I have created the javascript like this:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    // Select/Deselect checkboxes based on header checkbox
    function SelectheaderCheckboxesTeacher() {
        if ($("#selectallTeachers").val() == 'on') {
            $('.caseTeacher').attr('checked', 'checked');
            $("#selectallTeachers").val('off');
        }
        else if ($("#selectallTeachers").val() == 'off') {
            $('.caseTeacher').removeAttr("checked");
            $("#selectallTeachers").val('on');
        }

        $(".caseTeacher").click(function () {
            if ($(".caseTeacher").length == $(".caseTeacher:checked").length) {
                $("#selectallTeachers").attr("checked", "checked");
                $("#selectallTeachers").val('off');
            } else {
                $("#selectallTeachers").removeAttr("checked");
                $("#selectallTeachers").val('on');
            }
        });
    }
    // if all checkbox are selected, check the selectallTeachers checkbox
    // and viceversa   
&lt;/script&gt;  
</code></pre>

<p>For a buttonclick event I written this:</p>

<pre><code>protected void btnDeleteSelectedMessages_Click(object sender, EventArgs e)
{
    if (currentGridView == null)
        setCurrentGridView();

    //controleer voor elke rij welke checkbox is geselecteerd
    foreach (GridViewRow row in currentGridView.Rows)
    {
        CheckBox cb = (CheckBox)row.FindControl("chkPaid");
        Guid messageID = (Guid)currentGridView.DataKeys[row.DataItemIndex].Value;

        //als de checkbox is geselecteerd het bericht verwijderen
        if (cb != null &amp;&amp; cb.Checked)
        {
            if (currentGridView.ID.Equals("Messages"))
                b.BussinesMessageReceiver.DeleteMessageReceiver(messageID, MessageBoxPerson);
            else if (currentGridView.ID.Equals("MessagesSent"))
                b.BussinesMessage.DeleteMessageSender(messageID);
            else //MessagesDeleted
                b.BussinesMessage.DeleteMessage(messageID, (Page.Server.MapPath("~/Upload/") + messageID));
            continue;
        }
    }
    btnDeleteSelectedMessages.Enabled = false;
    selectLocation.Visible = false;
    clearSelectedMessageSession();

    //Update the GridView
    BindGridView();
}
</code></pre>

<p>It shows an error on the line</p>

<pre><code>CheckBox cb = (CheckBox)row.FindControl("chkPaid");
</code></pre>

<p>because I have created by input type not directly by checkbox.</p>
