By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

asp:Checkbox Text attribute-- how to do this?

P: n/a
Hi everyone,

This is a silly one I'm sure, but I'm having a whale of a time putting some
text into my asp checkbox. Here's what I'd like to do:

<asp:CheckBox runat="server" Text='<%#DataBinder.Eval(Container.DataItem,
"OptionLabel")%> Fields' ID="chkDBFields"/>

....unfortunately, it doesn't work. The DataBinder text is evaluated
literally, so all I get on-screen is the word "Fields". And whenever I try
playing with the quotes I receive various syntax errors. Could someone show
me how to get this to work, so that I have my data-bound field and the word
"Fields" appended to it in the checkbox text? Thanks very much.
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hello,
You may want to try:

<asp:CheckBox runat="server" Text='<%#DataBinder.Eval(Container.DataItem,
"OptionLabel") & "Fields" %>' ID="chkDBFields"/>

I have not tried this in a checkbox, but it has worked for me in textboxes.

Regards,
Cesar

"Jim Bancroft" wrote:
Hi everyone,

This is a silly one I'm sure, but I'm having a whale of a time putting some
text into my asp checkbox. Here's what I'd like to do:

<asp:CheckBox runat="server" Text='<%#DataBinder.Eval(Container.DataItem,
"OptionLabel")%> Fields' ID="chkDBFields"/>

....unfortunately, it doesn't work. The DataBinder text is evaluated
literally, so all I get on-screen is the word "Fields". And whenever I try
playing with the quotes I receive various syntax errors. Could someone show
me how to get this to work, so that I have my data-bound field and the word
"Fields" appended to it in the checkbox text? Thanks very much.

Nov 19 '05 #2

P: n/a
My experience that it will not work.The reason is that you have ranat
=server attribute.
You should use ItemDataBound event to write the text.
Shimon
"Jim Bancroft" <as******@nowhere.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi everyone,

This is a silly one I'm sure, but I'm having a whale of a time putting
some text into my asp checkbox. Here's what I'd like to do:

<asp:CheckBox runat="server" Text='<%#DataBinder.Eval(Container.DataItem,
"OptionLabel")%> Fields' ID="chkDBFields"/>

...unfortunately, it doesn't work. The DataBinder text is evaluated
literally, so all I get on-screen is the word "Fields". And whenever I
try playing with the quotes I receive various syntax errors. Could
someone show me how to get this to work, so that I have my data-bound
field and the word "Fields" appended to it in the checkbox text? Thanks
very much.

Nov 19 '05 #3

P: n/a
Thank you, Cesar. What I wound up doing was this:

<asp:CheckBox runat="server"
Text=<%#Convert.ToString(DataBinder.Eval(Container .DataItem, "OptionLabel"))
+ " Database Fields"/>

It's what worked for me. I hope someone can make use of it too.

-Jim
Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.