For the life of me I cannot bind the Checked property of a CheckBox control within a TemplateField (declaritively).
I have tried:
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="deactivated" runat="server" checked="<%#Eval("Deactivated")%>"></asp:CheckBox>
</ItemTemplate>
<asp:TemplateField>
and
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="deactivated" runat="server" checked="<%#Eval(Container.DataItem, "Deactivated")%>"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
</asp:TemplateField>
I keep seeing a warning stating:
Cannot create an object of type 'System.Boolean' from it's string representation' 'for the 'Checked' property
What am I doing wrong?
It may be because of the double quotes you've used. Try:
checked= '<%# Eval("Deactivated") %>'