469,887 Members | 1,892 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,887 developers. It's quick & easy.

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 6247
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Meerkat | last post: by
2 posts views Thread by tjonsek | last post: by
1 post views Thread by gh | last post: by
reply views Thread by Mark | last post: by
2 posts views Thread by MattB | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.