C# - ASPX - Checkbox needs to be checked only if certain text is in the DB
<p>I'm looking for a small piece of code that allows me the have a checkbox checked or not checked depending on the text value of the Checkbox.</p>

<p>For example: If the text value of the checkbox is "Yes" it needs to be checked. If it's not "Yes" it shouldn't be checked.</p>

<p>This is what I have:</p>

<p>ASPX-page:</p>

<pre><code>&lt;asp:TemplateField HeaderText="Contract Check" SortExpression="Contract_Check" ItemStyle-Wrap="false"&gt;
            &lt;EditItemTemplate&gt;&lt;/EditItemTemplate&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:CheckBox ID="chk_contract_check" Checked='&lt;%# contractCheck(Container.DataItem) %&gt;' Text='&lt;%# Bind("Contract_Check") %&gt;' runat="server" Enabled="false" /&gt;
            &lt;/ItemTemplate&gt;
            &lt;FooterTemplate&gt;&lt;/FooterTemplate&gt;
        &lt;/asp:TemplateField&gt;
</code></pre>

<p>Code Behind File:</p>

<pre><code>protected String contractCheck(CheckBox obj)
    {
        if (obj.Text == "Prior Transition")
            return "True";
        else
            return "False";}
</code></pre>

<p>However this is not working. Do you guys have any idea how I can get this too work?
Thanks</p>

<p>Kevin</p>
