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.
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.
This is what I have:
ASPX-page:
<asp:TemplateField HeaderText="Contract Check" SortExpression="Contract_Check" ItemStyle-Wrap="false">
<EditItemTemplate></EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chk_contract_check" Checked='<%# contractCheck(Container.DataItem) %>' Text='<%# Bind("Contract_Check") %>' runat="server" Enabled="false" />
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:TemplateField>
Code Behind File:
protected String contractCheck(CheckBox obj)
{
if (obj.Text == "Prior Transition")
return "True";
else
return "False";}
However this is not working. Do you guys have any idea how I can get this too work? Thanks
Kevin