CheckBoxList - how to prevent labels from wraping?

  • Thread starter Thread starter MattB
  • Start date Start date
M

MattB

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
 
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
 
Back
Top