Re: How do I do data binding with a checkbox?
From: Alan Silver (alan-silver_at_nospam.thanx)
Date: 02/22/05
- Next message: Alan Silver: "How do I cast something as a user control?"
- Previous message: Alan Silver: "Re: How do I pass a DateTime to a custom control ?"
- In reply to: Alan Silver: "How do I do data binding with a checkbox?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 20:52:04 +0000
>Any ideas what I'm doing wrong? TIA
I found an answer to this, so I'll post it here in case it's of use to
anyone.
The easiest way I found was to create a function :-
Boolean TrueIfY(string YN) {
if (YN == "y") {return true;}
else {return false;}
}
and use this in the ItemTemplate ...
<asp:CheckBox ID="chkPhotosShow" Text=""
Checked='<%#TrueIfY((string)DataBinder.Eval(Container.DataItem,
"ShowEvent"))%>' Runat="Server" />
This worked fine. I still can't work out *why* this works when the
previous code didn't, as both ways you seem to be passing a Boolean
value. Still, at least it works ;-)
Hope this is of use to someone.
-- Alan Silver (anything added below this line is nothing to do with me)
- Next message: Alan Silver: "How do I cast something as a user control?"
- Previous message: Alan Silver: "Re: How do I pass a DateTime to a custom control ?"
- In reply to: Alan Silver: "How do I do data binding with a checkbox?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|