473,320 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

CheckBoxList - how to prevent labels from wraping?

Hi I have a form with a CheckBoxList that gets bound at runtime. I split it
into columns if there are a lot of items, but the formatting of those
columns isn't what I was looking for. Specifically, I don't like how the
labels wrap and would like to prevent them from wrapping, but I don't see a
property that applies to this. How can I keep the labels on one line?
Thanks!

Matt
Nov 18 '05 #1
2 6465
I looked into a property based approach and I don't think that's
supported.

I'd try wrapping the text in the ListItem in a <nobr> tag. The syntax
would be a bit different depending on how you're doing your
databinding.

You may set this to using the ListItem.Text property on the server
side, or if you're doing your databinding in the ASPX you'd use
something like
<asp:listitem><nobr><%#databinder.eval(...)%></nobr></asp:listitem>

As an example, here's the code you'd use if you weren't databinding:
<asp:CheckBoxList id="checkboxlist1"
AutoPostBack="True"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Flow"
TextAlign="Right"
OnSelectedIndexChanged="Check_Clicked"
runat="server">

<asp:ListItem><nobr>Item 1</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 2</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 3</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 4</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 5</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 6</nobr></asp:ListItem>
</asp:CheckBoxList>

- Jon
http://weblogs.asp.net/jgalloway

Nov 18 '05 #2
Awesome! the <nobr> tags worked like a charm. Thanks!

Matt

jongalloway wrote:
I looked into a property based approach and I don't think that's
supported.

I'd try wrapping the text in the ListItem in a <nobr> tag. The syntax
would be a bit different depending on how you're doing your
databinding.

You may set this to using the ListItem.Text property on the server
side, or if you're doing your databinding in the ASPX you'd use
something like
<asp:listitem><nobr><%#databinder.eval(...)%></nobr></asp:listitem>

As an example, here's the code you'd use if you weren't databinding:
<asp:CheckBoxList id="checkboxlist1"
AutoPostBack="True"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Flow"
TextAlign="Right"
OnSelectedIndexChanged="Check_Clicked"
runat="server">

<asp:ListItem><nobr>Item 1</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 2</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 3</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 4</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 5</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 6</nobr></asp:ListItem>
</asp:CheckBoxList>

- Jon
http://weblogs.asp.net/jgalloway

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tony | last post by:
I have a repeater that renders multiple checkboxlists that are set up with a repeat direction of horizontal. Because the labels for each checkbox are different in length only the individual...
4
by: Meerkat | last post by:
Hello. Can anyone tell me if there is ANY way to prevent the user changing the values in a checkboxlist. I just want to use it for information only. Disabling it is not an option as it results...
0
by: MattB | last post by:
The relates to my question earlier about how to format labels in a CBL (CheckBoxList) to not wrap. I think I've found an approach that will probably work when I can figure out how to refer to a...
5
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
7
by: ThunderMusic | last post by:
Hi, I have a CheckBoxList and I want to add some javascript code to each CheckBox created by this CheckBoxList. I tried iterating through all items of the list, all the controls, do a FindControl,...
2
by: tjonsek | last post by:
Is it possible to concat to fields from a dataset together to create the checkboxlist labels? I'd like to create a form with a checkboxlist with the text of the label for each item coming from a...
1
by: gh | last post by:
I am using .net v1.1. I have a checkboxlist control that is populated from a datasource. The label for each checkbox varies in length and some of them wrap. How can I set the width for the...
0
by: Mark | last post by:
Would someone be so kind as to tell me if there's a way of adding a label to the oCheckBoxList.Controls collection and having it render? For example, I'm looking for this output (# represents a...
2
by: MattB | last post by:
I'm still on .Net 1.1 if that makes a difference. I have a CheckBoxList in my application that I want to use a OnDataBinding event to do some conditional changes to the labels at run time. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.