I was wondering if it's possible to set the checked propery of a checkbox, using a bool variable form the repeater's datasource?
I've tried several ways but without any success...:
<asp:Repeater ID="rpt" runat="server">
<itemTemplate>
<asp:CheckBox runat="server" CssClass="checkbox"
Checked="<%#Eval("IsDefault").ToString().ToLower()%>"
ID="isDefaultCheckBox"/>
</itemTemplate>
</asp:Repeater>
<asp:Repeater ID="rpt" runat="server">
<itemTemplate>
<asp:CheckBox runat="server" CssClass="checkbox"
Checked="<%# DataBinder.Eval(Container.DataItem, "IsDefault")%>"
ID="isDefaultCheckBox"/>
</itemTemplate>
</asp:Repeater>
IsDefault is a field in a class View:
public bool IsDefault
The repeater's DataSource is List.
Another solution is handling ItemDataBound event:
...
The problem with the code is actually the fact that you are nesting double quotes
should be
I'm fairly sure that it should work this way:
By the way, there's a missing
<
in your first approach:Edit: (since you've also edited your question and corrected it)
Now there's something else wrong, you've two consecutive quotes here:
Old question, but I solved this in my application using something much simpler: