Last post Nov 15, 2005 03:47 PM by jjohns09
Nov 14, 2005 11:20 PM|Baatezu|LINK
I'm trying to use a Repeater control with some checkboxes in it. I am having no luck getting my code to set the Checked value of the checkbox. The bits of code I have attempted to use that have been recommended to me from other sites
<asp:CheckBox Checked='<%# DataBinder.Eval(Container, "DataItem.Active").ToString(); %>' </asp:CheckBox>
<asp:CheckBox Checked='<%# (DataBinder.Eval(Container, "DataItem.Active") ? "True" : "False") %>' </asp:CheckBox>
I've used a few variants on this, but they all turn out the same, there is an error loading the module.
I used these because if I use
<asp:CheckBox Checked='<%# DataBinder.Eval(Container, "DataItem.Active") %>' </asp:CheckBox>
I get a Specified Cast is Not Valid, since, I assume, the value in Active is a boolean.
Any pointers or tricks to getting DNN to work so I can set the checked value of a checked box based on the dataset I bound it to?
Nov 15, 2005 07:50 AM|jjohns09|LINK
Nov 15, 2005 12:13 PM|Baatezu|LINK
Nov 15, 2005 01:45 PM|jjohns09|LINK
So, if I understand everything correctly, you are not using a business object but rather binding your repeater to a dataset that has an 'Active' columname that is an integer value. As everything seems to fail when trying to set the Checked value, you might
try to use a Helper function such;
Checked='<%# IsActive(DataBinder.Eval(Container.DataItem, "Active")) %>'
In your codebehind try this:
public bool IsActive(object activeValue)
if (activeValue != null)
Nov 15, 2005 01:54 PM|Baatezu|LINK
Nov 15, 2005 02:11 PM|Baatezu|LINK
Nov 15, 2005 03:47 PM|jjohns09|LINK
Glad that you got this working.
Please let us know how you make out with the remainder of your work.