473,503 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
3 3591
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1532
by: sklett | last post by:
I'm curious... asp:Panel renderes a <div> tag, right? And you can have text in a div tag.... so why not have a Text property for the asp:panel control??
1
1641
by: BARTKO, Zoltan | last post by:
Hello folks, I have the following problem: I have a bunch of text files, I want to load them into a table where each file will be stored in one row. Question 1: Is there any way how to do...
1
1264
by: serge calderara | last post by:
Dear all, I have a datagrid which is bind to a databse table. One field of that table contains a filename. What I ma trying to do is to display the content of a cell to be an icon when the...
1
2143
by: paul.hester | last post by:
Hi all, I'm trying to display the a Page variable's value in the Text property of a CheckBox control in the aspx file: <asp:CheckBox ID="agreeTerms" Text="I agree to the <%# this.SiteName %>...
3
1679
by: Kevin Burton | last post by:
I have an XSD that is converted from a DTD that I am trying to clean up. There is a section in the XSD that looks like: <xs:element name="partnerID"> <xs:complexType mixed="true">...
9
8387
by: Erwin Moller | last post by:
Hi, Can anybody comment on this? In comp.lang.php I advised somebody to skip using: <script language="javascript"> and use: <script type="text/javascript"> And mr. Dunlop gave this response:
0
1393
by: K B | last post by:
Hi, I would like to show an image in the text position of radiobuttonlist listitems. Not from a dataset, just set in the html or code behind. Example (x = radio button) x Red light image...
4
1701
by: jeddiki | last post by:
Hi, I am trying to harmonize my type face with my blog. this is what I have: http://www.expert-world.com/im/images/trash3.jpg Use see the USEFUL CONNECTIONS ?
2
1301
by: bigguyjoe | last post by:
I am using modx to create a site at www.mmwri.com. The navigation is dynamically generated by Wayfinder. I am trying to style the text with the navigation div. I can make it look fine in any Mac...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.