C# - ASPX - Checkbox needs to be checked only if certain text is in the DB

RibFeetObsele

New Member
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:\[code\]<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\]Code Behind File:\[code\]protected String contractCheck(CheckBox obj) { if (obj.Text == "Prior Transition") return "True"; else return "False";}\[/code\]However this is not working. Do you guys have any idea how I can get this too work?ThanksKevin
 
Back
Top